Coder Social home page Coder Social logo

augur-abi's Introduction

augur-abi

Build Status Coverage Status npm version

augur-abi is a standalone JavaScript module that provides Ethereum contract ABI data serialization methods. ABI encoding is needed to invoke functions on Ethereum smart contracts.

This module presently supports only Serpent contracts; it's my intention to add Solidity data type support when I have time!

Installation

$ npm install augur-abi

Usage

To use augur-abi in Node.js, just require it:

var augur_abi = require("augur-abi");

A minified, browserified file dist/augur-abi.min.js is included for use in the browser. Including this file simply attaches the augur_abi object to window:

<script src="dist/augur-abi.min.js" type="text/javascript"></script>

The encode method encodes the full ABI data (prefix + parameters) needed for a contract function call. For example, to encode a method named double that takes a single integer parameter with a value of 3:

var encoded = augur_abi.encode({
    method: "double",
    signature: "i",
    params: [3]
});
// encoded:
'0x6ffa1caa0000000000000000000000000000000000000000000000000000000000000003'

encoded is the concatenation of the method's prefix 0x6ffa1caa, which is derived from the name of the method "double" and its signature "i", and the encoded parameter value, [3].

"Signature" refers to the short-form Serpent parameter signature, which allows i (int256), a (variable-sized int256 array) and s (variable-length string/bytes). For example, a method which takes parameter types int256, string, int256, int256, int256, array would have signature isiiia.

Tests

Unit tests are in the test directory, and can be run with mocha:

$ npm test

augur-abi's People

Contributors

tinybike avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.