0

Hi I am trying to call the function transfer , however in remix it says that I can only call the transferOwnership method, here is my solidity contract

 pragma solidity ^0.4.18;

contract Ownable {

address public owner;

function Ownable() public {
    owner = msg.sender;
}

modifier onlyOwner() {
    require(msg.sender == owner);
    _;
}

function transferOwnership(address newOwner) public onlyOwner {
    owner = newOwner;
}

}

contract SimpleTokenCoin is Ownable {

string public constant name = "Vozik coin";

string public constant symbol = "VZC";

uint32 public constant decimals = 18;

uint public totalSupply = 1000000;

mapping (address => uint) balances;

mapping (address => mapping(address => uint)) allowed;

function mint(address _to, uint _value) public onlyOwner {
    assert(totalSupply + _value >= totalSupply && balances[_to] + _value >= balances[_to]);
    balances[_to] += _value;
    totalSupply += _value;
}

function balanceOf(address _owner) public constant returns (uint balance) {
    return balances[_owner];
}

function transfer(address _to, uint _value) public returns (bool success) {
    if(balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]) {
        balances[msg.sender] -= _value; 
        balances[_to] += _value;
        Transfer(msg.sender, _to, _value);
        return true;
    } 
    return false;
}

function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
    if( allowed[_from][msg.sender] >= _value &&
        balances[_from] >= _value 
        && balances[_to] + _value >= balances[_to]) {
        allowed[_from][msg.sender] -= _value;
        balances[_from] -= _value; 
        balances[_to] += _value;
        Transfer(_from, _to, _value);
        return true;
    } 
    return false;
}

function approve(address _spender, uint _value) public returns (bool success) {
    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
    return true;
}

function allowance(address _owner, address _spender) public constant returns (uint remaining) {
    return allowed[_owner][_spender];
}

event Transfer(address indexed _from, address indexed _to, uint _value);

event Approval(address indexed _owner, address indexed _spender, uint _value);

}

Does anybody know how I can call the transferFunction .

Here is my js code for the console

function callContract(ABI, Address) {

   var Contract = eth.contract(ABI).at(Address);
   var getData = Contract.transfer.getData("0x5adf9a54813be6f62820e5907c7ed082898d718a", 10);    //reword

   eth.sendTransaction(
      { to: Address,
        from: eth.coinbase,
        data: getData
      }
   );
}
0

You have selected "Ownable" contract, you need to select "SimpleTokenCoin" contract to see "transfer" function

  • Ah of course! silly me being stuck on this for an hour haha thanks a lot bro! – kquinn May 28 '18 at 15:27

Your Answer

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

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