创作人 Leo
编辑时间 Fri Jul 29,2022 at 19:47
下载go语言相关工具
直接地址
通过 sol 源文件生成 abi 信息
./solc-static-linux –abi ./EIP20.sol
注意:solc 程序需要匹配 solidity 对应版本
或者拷贝 truffle 导出的 json 中 abi 字段值到单独文件也可以
例 :truffle 原导出文件
{
"contractName": "EIP20",
"abi": [
{
"inputs": [
{
"internalType": "uint256",
"name": "_initialAmount",
"type": "uint256"
},
...
拷贝这个 abi 数组到新的文件
[
// ...
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "_spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "_value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "success",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
// ...
]
通过 abi 文件导出
/usr/local/geth/abigen –abi eip20token.abi –pkg erc20token –type EIP20Token –out erc20token.go
参考