Ich führe einen HelloWorld-Vertrag aus.
pragma solidity ^0.4.2;
contract HelloWorld {
uint public balance;
function Helloworld(){
balance = 1000;
}
}
Nach truffle compile
und truffle migrate
Befehl habe ich den folgenden Befehl in der Truffle-Konsole ausgeführt:
HelloWorld.balance.call()
Fehler:
TypeError: Eigenschaft „call“ von undefined bei evalmachine.:1:19 bei ContextifyScript.Script.runInContext (vm.js:35:29) bei Object.exports.runInContext (vm.js:67:17) bei TruffleInterpreter kann nicht gelesen werden. interpretiere (/usr/lib/node_modules/truffle/lib/repl.js:99:17) bei bound (domain.js:280:14) bei REPLServer.runBound [als eval] (domain.js:293:12) bei REPLServer. (repl.js:545:10) bei emitOne (events.js:96:13) bei REPLServer.emit (events.js:188:7) bei REPLServer.Interface._onLine (readline.js:239:10)
truffle(default)> HelloWorld.deployed()
Contract {
contract:
Contract {
_eth:
Eth {
_requestManager: [Object],
getBalance: [Object],
getStorageAt: [Object],
getCode: [Object],
getBlock: [Object],
getUncle: [Object],
getCompilers: [Object],
getBlockTransactionCount: [Object],
getBlockUncleCount: [Object],
getTransaction: [Object],
getTransactionFromBlock: [Object],
getTransactionReceipt: [Object],
getTransactionCount: [Object],
call: [Object],
estimateGas: [Object],
sendRawTransaction: [Object],
sendTransaction: [Object],
sign: [Object],
compile: [Object],
submitWork: [Object],
getWork: [Object],
coinbase: [Getter],
getCoinbase: [Object],
mining: [Getter],
getMining: [Object],
hashrate: [Getter],
getHashrate: [Object],
syncing: [Getter],
getSyncing: [Object],
gasPrice: [Getter],
getGasPrice: [Object],
accounts: [Getter],
getAccounts: [Object],
blockNumber: [Getter],
getBlockNumber: [Object],
iban: [Object],
sendIBANTransaction: [Function: bound transfer] },
transactionHash: null,
address: '0x83367f99f17e89248c32f4a323c027446246e650',
abi: [ [Object], [Object] ],
Helloworld:
{ [Function: bound ]
request: [Function: bound ],
call: [Function: bound ],
sendTransaction: [Function: bound ],
estimateGas: [Function: bound ],
getData: [Function: bound ],
'': [Circular] },
balance:
{ [Function: bound ]
request: [Function: bound ],
call: [Function: bound ],
sendTransaction: [Function: bound ],
estimateGas: [Function: bound ],
getData: [Function: bound ],
'': [Circular] },
allEvents: [Function: bound ] },
Helloworld:
{ [Function]
call: [Function],
sendTransaction: [Function],
request: [Function: bound ],
estimateGas: [Function] },
balance:
{ [Function]
call: [Function],
sendTransaction: [Function],
request: [Function: bound ],
estimateGas: [Function] },
allEvents: [Function: bound ],
address: '0x83367f99f17e89248c32f4a323c027446246e650',
transactionHash: null }
Mach einfach
HelloWorld.deployed().balance.call()
In diesem Thread wird darauf verwiesen: https://ethereum.stackexchange.com/a/11944/16743 . Truffle v.3.x erfordert, dass Sie eine Funktion oder Variable .then()
gemäß der Dokumentation hier aufrufen: http://truffleframework.com/tutorials/upgrading-from-truffle-2-to-3#contract-abstractions-deployed-is -jetzt-dannable
Ronak Patel
{ [String: '0'] s: 1, e: 0, c: [ 0 ] }
Es sollte 1000 sein, da die Balance-Variable auf 1000 gesetzt ist. Entschuldigung, ich bin neu darin.Tjaden Hess
HelloWorld
.