sol_abi 0.1.0+1 copy "sol_abi: ^0.1.0+1" to clipboard
sol_abi: ^0.1.0+1 copied to clipboard

ABI JSON, metadata JSON, and NatSpec generation for the sol_pkgs Solidity compiler.

sol_abi #

ABI JSON generation and ABI encoding/decoding for the sol_pkgs Solidity compiler.

Features #

Module Description
AbiGenerator Generates the Solidity ABI JSON from a ContractDefinition
AbiEncoder ABI-encodes Dart values for function calls and return data

ABI JSON generation #

import 'package:sol_abi/sol_abi.dart';

final json = AbiGenerator().generateJson(contractAst);
print(json);
// [
//   {
//     "type": "function",
//     "name": "getSum",
//     "inputs": [{"name": "a", "type": "uint256"}, {"name": "b", "type": "uint256"}],
//     "outputs": [{"name": "", "type": "uint256"}],
//     "stateMutability": "pure"
//   }
// ]

ABI encoding #

import 'package:sol_abi/sol_abi.dart';
import 'package:sol_types/sol_types.dart';

final enc = AbiEncoder();
final calldata = enc.encode([
  (uint256Type, 1),
  (uint256Type, 2),
]);
// 64 bytes: 0x00…01 0x00…02

Supported ABI types #

Solidity type Status
uint8uint256, int8int256
bool
address
bytes1bytes32
bytes
string
T[] / T[N]
tuple (struct) Planned

Dependencies #

  • sol_support — foundation
  • sol_astContractDefinition, FunctionDefinition, Parameter
  • sol_typesSolType hierarchy for encoder
0
likes
140
points
101
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

ABI JSON, metadata JSON, and NatSpec generation for the sol_pkgs Solidity compiler.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

sol_ast, sol_support, sol_types

More

Packages that depend on sol_abi