0

I am trying to transfer ERC 20 token using web3.js. Below is my code:

<script type="text/javascript">
    var web3;
    function send() {
        if (typeof web3 !== 'undefined') {
            web3 = new Web3(web3.currentProvider);
        } else {
            web3 = new Web3(new Web3.providers.HttpProvider("http://110.219.35.167:8545"));
        }
        if (!web3.isConnected()) {
            console.log('not-connected');
        } else {
            var theContract=web3.eth.contract([{my_abi}])
            var contractInstance = theContract.at('0x7b0CB0481E20490B030DeB3F292b61605EcEf050')
            web3.personal.unlockAccount('<?php echo $this->common->get_address() ?>','<?php echo $this->db_model->select('passphrase', 'member', array('id'=>$this->session->member_id)) ?>',100000)
            contractInstance.transfer('0xca2e4a5db17962d1e5ce44367731e217da8901b9',web3.toWei(1),{from:'<?php echo $this->common->get_address() ?>', gas:100})

            alert('Transfer Successful. Check confirmation status');
        }
    }
</script>

but getting the below error:Error: insufficient funds for gas * price + value

  • Just a guess, but the balance of your account is probably less than gas * price + value. – smarx Apr 21 '18 at 12:27
  • i have 15000+ token and 0.01 eth – Haren Sarma Apr 21 '18 at 12:32
  • 1
    Either gas * price + value is greater than 0.01 ether (unlikely) or the from account does not actually have 0.01 ether in it. – smarx Apr 21 '18 at 12:35
  • thanks. now it is sending ether instead of my token ! – Haren Sarma Apr 21 '18 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.