1

When I am trying to call ERC20 token transfer function from another contract (contract to contract call) in ethereum private blockchain network is not working, but if I try to call directly from js it's working.

Below I have shown the contract and js call.

ERC20.sol

function transfer(address sender, address receiver, uint256 numTokens) public returns (bool) 
{
    require(numTokens <= balances[admin]);
    balances[admin] = balances[admin].sub(numTokens);
    balances[receiver] = balances[receiver].add(numTokens);
    emit Transfer(admin, receiver, numTokens);
    return true;
}

ABcontract.sol

function tokentransfer(address sender, address receiver) public returns (bool) {
    ERC20Basic instance = ERC20Basic(erc20address);
    instance.transfer(sender,account,1000);
    return true;
}

app.js

tokentransfer:function(){
    ABcontract.deployed().then(function(instance){
      instance.tokentransfer(sender,receiver,{from:sender,gas:4600000});
    })
},

Sender have 1000 tokens by using ERC20 createtoken function.

Truffle v4.1.15 (core: 4.1.15)
Solidity v0.4.25 (solc-js)
node v10.19.0
Network : Private blockchain (Note:It's working in testrpc)

Help will be appreciated.

1 Answer 1

1

It's because of your oldest version of ethereum privatenet blockchain. Update and upgrade your geth,go and truffle versions.

1
  • This is unlikely to be a correct answer. Commented Mar 24, 2021 at 9:05

Your Answer

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

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