Skip to content

Instantly share code, notes, and snippets.

@TOMOAKI12345
Last active August 29, 2015 14:26
Show Gist options
  • Save TOMOAKI12345/c16e5d25fdeab6a081b9 to your computer and use it in GitHub Desktop.
Save TOMOAKI12345/c16e5d25fdeab6a081b9 to your computer and use it in GitHub Desktop.
token instance error
// After running
] Protocol Versions: [61 60], Network Id: 101
I0801 18:25:42.221005 22260 backend.go:333] Blockchain DB Version: 3
I0801 18:25:42.225142 22260 chain_manager.go:251] Last block (#2971) 11514de287ab8a3b01c2005213172b3150a00c2cbbc5de169700ad631f2a5d40 TD=759914948
I0801 18:25:42.265087 22260 cmd.go:121] Starting Geth/v0.9.36/darwin/go1.4.2
I0801 18:25:42.265172 22260 server.go:311] Starting Server
I0801 18:25:44.390958 22260 nat.go:111] mapped network port udp:30303 -> 30303 (ethereum discovery) using UPNP IGDv1-IP1
I0801 18:25:44.460799 22260 udp.go:205] Listening, enode://a9405e4dbfe2f4f63b4dd825a68e409bc227f0a4d58d77072a5c82a063e26bb21c310d3d7831db536a4d14498a0f8f71a8ff8ad9549efc6e37b1c510182cf1d3@49.135.68.148:30303
I0801 18:25:44.461140 22260 backend.go:554] Server started
I0801 18:25:44.461754 22260 server.go:548] Listening on [::]:30303
I0801 18:25:44.462259 22260 ipc_unix.go:76] IPC service started (/tmp/eth/161/geth.ipc)
instance: Geth/v0.9.36/darwin/go1.4.2
datadir: /tmp/eth/161
coinbase: 0x60a8d1f635b887cde014680504ae862acab703cb
at block: 2971 (2015-08-01 18:02:08)
modules: admin:1.0 db:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 shh:1.0 txpool:1.0 web3:1.0
// this is the contract
var supply = 10000;
var tokenSource = ' contract token { mapping (address => uint) public coinBalanceOf; event CoinTransfer(address sender, address receiver, uint amount); /* Initializes contract with initial supply tokens to the creator of the contract */ function token(uint supply) { coinBalanceOf[msg.sender] = (supply || 10000); } /* Very simple trade function */ function sendCoin(address receiver, uint amount) returns(bool sufficient) { if (coinBalanceOf[msg.sender] < amount) return false; coinBalanceOf[msg.sender] -= amount; coinBalanceOf[receiver] += amount; CoinTransfer(msg.sender, receiver, amount); return true; } }'
var tokenCompiled = eth.compile.solidity(tokenSource)
var tokenContract = web3.eth.contract(tokenCompiled.token.info.abiDefinition);
var supply = 100000
var token = tokenContract.new( supply, { from:web3.eth.accounts[0], data:tokenCompiled.token.code, gas: 1000000 }, function(e, contract){ if(!e) { if(!contract.address) { console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined..."); } else { console.log("Contract mined! Address: " + contract.address); console.log(contract); } } })
miner.start()
miner.stop()
> token
{
address: '0xaea0e4f0923262d5db45eee8417542358f040983',
transactionHash: '0x4d9e286b0f536b2f02b4fe6298912e79057e6d1aaab7746f6ef907421b2779fc',
CoinTransfer: function (),
allEvents: function (),
coinBalanceOf: function (),
sendCoin: function ()
}
// this error
> token.coinBalanceOf.call(eth.accounts[0])
to not valid, is required
at InvalidResponse (<anonymous>:-59174:-42)
at send (<anonymous>:-117082:-42)
at call (<anonymous>:-105818:-42)
at call (<anonymous>:-89654:-42)
at <anonymous>:1:1
> token.coinBalanceOf.call()
to not valid, is required
at InvalidResponse (<anonymous>:-59174:-27)
at send (<anonymous>:-117082:-27)
at call (<anonymous>:-105818:-27)
at call (<anonymous>:-89654:-27)
at <anonymous>:1:1
> token.coinBalanceOf.call()
to not valid, is required
at InvalidResponse (<anonymous>:-59174:-27)
at send (<anonymous>:-117082:-27)
at call (<anonymous>:-105818:-27)
at call (<anonymous>:-89654:-27)
at <anonymous>:1:1
> token.coinBalanceOf.sendTransaction(eth.accounts[0])
could not decode, from not valid, is required
at InvalidResponse (<anonymous>:-59174:-53)
at send (<anonymous>:-117082:-53)
at sendTransaction (<anonymous>:-105818:-53)
at sendTransaction (<anonymous>:-90311:-53)
at <anonymous>:1:1
>
> token.coinBalanceOf.call({to:eth.accounts[0]})
new BigNumber() not a number: [object Object]
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at encodeParams (<anonymous>:-6173:-47)
> token.coinBalanceOf.call({to:eth.accounts[0]})
new BigNumber() not a number: [object Object]
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at encodeParams (<anonymous>:-6173:-48)
> token.coinBalanceOf.call(eth.accounts[1], {to:eth.accounts[0]})
to not valid, is required
at InvalidResponse (<anonymous>:-59174:-65)
at send (<anonymous>:-117082:-65)
at call (<anonymous>:-105818:-65)
at call (<anonymous>:-89654:-65)
at <anonymous>:1:2
> token.coinBalanceOf.call(eth.accounts[1], {from: eth.accounts[1], to:eth.accounts[0]})
to not valid, is required
at InvalidResponse (<anonymous>:-59174:-88)
at send (<anonymous>:-117082:-88)
at call (<anonymous>:-105818:-88)
at call (<anonymous>:-89654:-88)
at <anonymous>:1:2
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment