原文:

什么是ABI

ABI是Application Binary Interface的缩写,字面意思 应用二进制接口,可以通俗的理解为 合约的接口说明。当合约被编译后,那么它的abi也就确定了。
我们先来看个极简单的合约和它的abi
pragma solidity ^0.4.4; contract test { string public a; function modify_a(string val) { a = val; } }
编译后的字节码
6060604052341561000c57fe5b5b60e18061001b6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630dbe671f146044578063efa3b144146067575bfe5b3415604b57fe5b60516098565b6040518082815260200191505060405180910390f35b3415606e57fe5b60826004808035906020019091905050609e565b6040518082815260200191505060405180910390f35b60005481565b60006005820260008190555060005490505b9190505600a165627a7a72305820e7910925075fb58319dd637b47520b821714dd11ad896cb6d8272151aff714690029
abi
[{"constant":true,"inputs":[],"name":"a","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"val","type":"uint256"}],"name":"modify_a","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"}]modify_a","outputs":[],"payable":false,"type":"function"}]
为了看起来更方便,把它格式化一下
[ { "constant": true, "inputs": [ ], "name": "a", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "val", "type": "uint256" } ], "name": "modify_a", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "type": "function" } ]