ABI Type Generator Package -- https://github.com/Mike-Stupich/typ3-cli
- Uses typed-objects in parameters instead of arrays to call contracts for position-agnostic calls
- Uses typed-objects in outputs, eliminating the need to guess what values they are
- Automatically chooses between a transaction and call on invocation via proxies
- Currently only supports ABI functions
- Fully typed contracts and rpc-calls
Returns an instance that provides a connection to a node with rpc methods as described in https://github.com/ethereum/wiki/wiki/JSON-RPC. Also has a .setEndpoint function for connecting to a different node
- json_abi The json abi of the smart contract to interact with
- [optional] outputMappings An object of arrays that hold mappings for un-named output parameters, it should match the same outputMappings file used for generating ABI_TYPE from
typ3-cli
Returns a contract instance of ABI_TYPE that has methods with the same mapping as the smart contract. ABI_TYPE is generated from the typ3-cli package to provide typing support for the contract instance. Each method provides encoding and decoding functions for input and output of the smart contract.
- contract_instance The contract instance to connect to the specified node
- node_instance The node to send calls to
- [optional] txObj Allows for default parameters such as
to, from, value, gas. Returns a contract instance that is connected to an existing node. Each method is directly invokable.
- myContract.myMethod
- encodeArguments(paramsObj)
- decodeArguments(encodedData)
- decodeReturnValue(encodedData)
- myContract.myMethod(paramsObj, txObj)
{
"constant": true,
"inputs": [
{ "name": "_a", "type": "uint256" },
{ "name": "_c", "type": "uint256" }
],
"name": "ppb",
"outputs": [{ "name": "b", "type": "uint256" }],
"type": "function"
},Given the above abi function, paramsObj would be:
{
_a: string | BigNumber | BN,
_c: string | BigNumber | BN
}And the returned value as the following shape
{
b: string
}If outputs was the following instead: "outputs": [{ "name": "", "type": "uint256" }],
We would have this:
{
0: string
}Unless a user supplied outputMapping was provided, then it would be:
const outputMappings = {
ppb: ["myName"]
}
{
"myName": string
}Contributors
- Henry Nguyen
- Mike Stupich
- Nicholas Lewanowicz
- Jaimin Darji