2017-06-04 238 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