2017-06-04 241 views
0

我用下面的Json一个问题:验证ABI 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这应该是添加到我的合同到我的钱包(钱包复仇)发送信息(在这种情况下,在我的覆盆子PI上发生了眨眼事件)

当我将这些行添加到我的以太坊钱包中的合同中时,它告诉我我的Json不正确。

我试着验证,但它给了我一个错误,我无法解决它。 (我是JSon的初学者)

有人可以帮助我验证g​​et/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 ] } 
} 

回答

1

您没有有效的JSON。 JSON具有键/值对,键是由双引号分隔的字符串。 JSON的详细信息,可以发现here

从复仇的文档,这是JSON在ABI一个例子:复仇合同

[{ 
"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": [] 
}] 

详细ABI可以发现here

0

什么你展示是来自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' } ]

你可以这样做

coinbase[0x20408a19c567a475545947600a95130f24f7C123].abi

访问ABI我不知道你的确切使用情况,但我建议你阅读有关智能合同abis here