2017-06-04 4 views
0

j'ai un problème avec la Json suivante:Valider ABI JSon (Ethereum)

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

Ce JSON est l'ABI et cela devrait être ajouter à mon contrat dans mon portefeuille (Ethereum Wallet) pour envoyer des informations (Dans ce cas, fait un événement de clignotement sur mon PI de framboise)

Lorsque j'ajoute ces lignes dans mon contrat dans mon éthereum, cela me dit que mon Json n'est pas correct.

J'ai essayé de valider, mais il me donne une erreur, et je ne peux pas le résoudre. (Je suis un débutant dans JSon)

Quelqu'un peut m'aider à valider la méthode get/set? être un format JSon valide?

Ceci est le retour complet avec coinbase (l'adresse et coinbase est modifiée):

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 ] } 
} 

Répondre

1

Vous n'avez pas JSON valide. JSON a des paires clé/valeur avec des clés étant des chaînes délimitées par des guillemets doubles. Les détails de JSON peuvent être trouvés here

De la documentation Ethereum ceci est un exemple de JSON dans l'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": [] 
}] 

Détails du contrat de Ethereum ABI peut être trouvé here

0

Ce que vous montriez est une charge utile de coinbase il contient beaucoup d'informations concernant votre demande, les contrats intelligents ABI est l'un d'entre eux.

En réalité, il est seulement
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' } ]

vous pouvez accéder à l'abi en faisant cela

coinbase[0x20408a19c567a475545947600a95130f24f7C123].abi

je ne sais pas votre cas précis d'utilisation, mais je vous suggère de lire les contrats sur les intelligents abis here