2

Hi i deployed a token contract in ethereum and managed to interact with it. solidity code :

contract Token {
  mapping (address => uint) public balances;
  event TokenSent(address sender, address receiver, uint amount);
  function Token(uint supply) {
    if (supply == 0) supply = 10000;
    balances[msg.sender] = supply;
  }
  function send(address receiver, uint amount) returns (bool ok) {
    if (balances[msg.sender] < amount) return false;
    balances[msg.sender] -= amount;
    balances[receiver] += amount;
    TokenSent(msg.sender, receiver, amount);
    return true;
  }
}

now im trying to send tokens to an account and i keep getting the following error:

new BigNumber() not a number: [object Object]10[object Object]
    at raise (web3.js:14426:29)
    at web3.js:14414:33
    at BigNumber (web3.js:13442:67)
    at BigNumber (web3.js:13452:29)
    at web3.js:2241:16
    at web3.js:2252:21
    at web3.js:950:32
    at web3.js:1598:12
    at web3.js:707:16
    at web3.js:706:20
    at web3.js:3991:46

I'm sending the following:

myContractInstance.send([{"receiver": "ed7a39b8cd4c217f99af29b5e5d7cbfd3c53030d"},{"amount": "100"}]),

if anyone could point me in the right direction that would be awesome!

2

1 Answer 1

2

You should call thus:

myContractInstance.send(
  "0xed7a39b8cd4c217f99af29b5e5d7cbfd3c53030d", // Better prefix with 0x
  100, // Just a number can work
  { from: tokenOwner }); // Rest of the transaction elements, if necessary.
20
  • what do you mean by "Rest of the transaction elements."? Sep 1, 2016 at 14:05
  • This github.com/ethereum/wiki/wiki/JavaScript-API#parameters-24 transaction object. Minus data: String, which is populated with .send( "0xed7a39b8cd4c217f99af29b5e5d7cbfd3c53030d", 100). Sep 1, 2016 at 14:08
  • ah i see, so everything thats optional i dont have to send really am i right? Sep 1, 2016 at 14:10
  • That's right. See if it works first. Sep 1, 2016 at 14:27
  • 1
    You might also want to consider implementing the ERC20 standard so your token can be accessible to the Mist wallet. The functionality of what you've called send is called transfer in ERC20. Calling it send is a bit confusing given that send is already a standard function to send ether and not transfer tokens.
    – o0ragman0o
    Sep 2, 2016 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.