我对下面的Json有一个问题:
[ { constant: false,
inputs: [Object],
name: 'set',
outputs: [],
type: 'function'
}, {
constant: true,
inputs: [],
name: 'get',
outputs: [Object],
type: 'function'
}, {
anonymous: false,
inputs: [Object],
name: 'ItBlinks',
type: 'event'
},
set: {
[Function: bound]
request: [Function: bound],
call: [Function: bound],
sendTransaction: [Function: bound],
estimateGas: [Function: bound],
getData: [Function: bound],
uint256: [Circular]
},
get: {
[Function: bound]
request: [Function: bound],
call: [Function: bound],
sendTransaction: [Function: bound],
estimateGas: [Function: bound],
getData: [Function: bound],
'': [Circular]
},
allEvents: [Function: bound],
ItBlinks: {
[Function: bound] uint256: [Function: bound]
}
}此JSon是ABI,应该将其添加到我的合同中,并将其添加到我的钱包(以太钱包)以发送信息(在本例中,在我的树莓派上创建了一个闪烁事件)
当我将这些行添加到我的以太钱包的合同中时,它告诉我我的Json不正确。
我尝试过验证,但它给了我一个错误,我无法解决它。(我是JSon的初学者)
有人能帮我验证get / set方法吗?成为有效的JSon格式?
这是coinbase的完整返回值(地址和coinbase已修改):
coinbase : 0x20408a19c567a475545947600a95130f24f7C123
{ _eth:
Eth {
_requestManager: { provider: [Object], polls: {}, timeout: null },
getBalance: { [Function] request: [Function: bound ], call: 'eth_getBalance' },
getStorageAt: { [Function] request: [Function: bound ], call: 'eth_getStorageAt' },
getCode: { [Function] request: [Function: bound ], call: 'eth_getCode' },
getBlock: { [Function] request: [Function: bound ], call: [Function] },
getUncle: { [Function] request: [Function: bound ], call: [Function] },
getCompilers: { [Function] request: [Function: bound ], call: 'eth_getCompilers' },
getBlockTransactionCount: { [Function] request: [Function: bound ], call: [Function] },
getBlockUncleCount: { [Function] request: [Function: bound ], call: [Function] },
getTransaction:
{ [Function]
request: [Function: bound ],
call: 'eth_getTransactionByHash' },
getTransactionFromBlock: { [Function] request: [Function: bound ], call: [Function] },
getTransactionReceipt:
{ [Function]
request: [Function: bound ],
call: 'eth_getTransactionReceipt' },
getTransactionCount: { [Function] request: [Function: bound ], call: 'eth_getTransactionCount' },
call: { [Function] request: [Function: bound ], call: 'eth_call' },
estimateGas: { [Function] request: [Function: bound ], call: 'eth_estimateGas' },
sendRawTransaction: { [Function] request: [Function: bound ], call: 'eth_sendRawTransaction' },
signTransaction: { [Function] request: [Function: bound ], call: 'eth_signTransaction' },
sendTransaction: { [Function] request: [Function: bound ], call: 'eth_sendTransaction' },
sign: { [Function] request: [Function: bound ], call: 'eth_sign' },
compile: { solidity: [Object], lll: [Object], serpent: [Object] },
submitWork: { [Function] request: [Function: bound ], call: 'eth_submitWork' },
getWork: { [Function] request: [Function: bound ], call: 'eth_getWork' },
coinbase: [Getter],
getCoinbase: { [Function] request: [Function: bound ] },
mining: [Getter],
getMining: { [Function] request: [Function: bound ] },
hashrate: [Getter],
getHashrate: { [Function] request: [Function: bound ] },
syncing: [Getter],
getSyncing: { [Function] request: [Function: bound ] },
gasPrice: [Getter],
getGasPrice: { [Function] request: [Function: bound ] },
accounts: [Getter],
getAccounts: { [Function] request: [Function: bound ] },
blockNumber: [Getter],
getBlockNumber: { [Function] request: [Function: bound ] },
protocolVersion: [Getter],
getProtocolVersion: { [Function] request: [Function: bound ] },
iban:
{ [Function]
fromAddress: [Function],
fromBban: [Function],
createIndirect: [Function],
isValid: [Function] },
sendIBANTransaction: [Function: bound ] },
transactionHash: null,
address: '0x9535eb707582edb3317dfdcdb365ce4186500C123',
abi:
[ { constant: false,
inputs: [Object],
name: 'set',
outputs: [],
type: 'function' },
{ constant: true,
inputs: [],
name: 'get',
outputs: [Object],
type: 'function' },
{ anonymous: false,
inputs: [Object],
name: 'ItBlinks',
type: 'event' } ],
set:
{ [Function: bound ]
request: [Function: bound ],
call: [Function: bound ],
sendTransaction: [Function: bound ],
estimateGas: [Function: bound ],
getData: [Function: bound ],
uint256: [Circular] },
get:
{ [Function: bound ]
request: [Function: bound ],
call: [Function: bound ],
sendTransaction: [Function: bound ],
estimateGas: [Function: bound ],
getData: [Function: bound ],
'': [Circular] },
allEvents: [Function: bound ],
ItBlinks: { [Function: bound ] uint256: [Function: bound ] }
}发布于 2017-06-04 21:56:09
您没有有效的JSON。JSON具有键/值对,键是由双引号分隔的字符串。有关JSON的详细信息,请访问here。
在以太文档中,这是ABI中的JSON示例:
[{
"type":"event",
"inputs": [{"name":"a","type":"uint256","indexed":true},
{"name":"b","type":"bytes32","indexed":false}],
"name":"Event"
}, {
"type":"event",
"inputs": [{"name":"a","type":"uint256","indexed":true},
{"name":"b","type":"bytes32","indexed":false}],
"name":"Event2"
}, {
"type":"event",
"inputs": [{"name":"a","type":"uint256","indexed":true},
{"name":"b","type":"bytes32","indexed":false}],
"name":"Event2"
}, {
"type":"function",
"inputs": [{"name":"a","type":"uint256"}],
"name":"foo",
"outputs": []
}]有关以太坊合同的详细信息,请访问here
发布于 2017-10-11 20:46:05
您显示的是来自coinbase的有效负载,它包含有关您的请求的大量信息,智能合约ABI就是其中之一。
实际上,它只是
abi:[ { constant: false, inputs: [Object], name: 'set', outputs: [], type: 'function' }, { constant: true, inputs: [], name: 'get', outputs: [Object], type: 'function' }, { anonymous: false, inputs: [Object], name: 'ItBlinks', type: 'event' } ]
您可以通过执行以下操作访问abi
coinbase[0x20408a19c567a475545947600a95130f24f7C123].abi
我不知道您的具体用例,但我建议您阅读有关智能合约的abis here
发布于 2019-04-27 01:50:56
我也有同样的问题。
问题在于JSON中的这个对象
您可能会从console.log对象中获取ABI。
您必须将此JSON对象转换为字符串,然后对其执行console.log操作,并获取将是有效JSON的输出。
https://stackoverflow.com/questions/44353836
复制相似问题