2

I am going through ethereum blockchain demo's and currently trying to call other contract deployed already on a local ethereum rpc in memory blockchain.

Using truffle and ethereum rpc i am testing this locally.

I create a contract compile and migrate it locally. then do the following command in powershell which gives me address

MyGameStore.deployed();

address:'0x1d6e1129725897cac1c332b1fcbcf4338d8f96c6'

now i copy above address i use it in my another contract like this

contract IScoreStore{
function GetGameScore(string name) returns(int);
}
 contract MyGameStore{
function showScore(string name) returns(int)
 {    IScoreStore store=    IScoreStore(0x1d6e1129725897cac1c332b1fcbcf4338d8f96c6);
return store.GetGameScore(name);
}
}

however when i do truffle compile , it gives me an error "this looks like an address but has invalid checksum"

My other contract is very much deployed and also it's method's work. then why above error? not sure what i am doing wrong. Can someone help.

2 Answers 2

1

First try to write your address in upper case letters. If it doesn't work try this converter

https://github.com/ethereum/EIPs/issues/55

1

Why do you need to hardcode the deployed contract address in another contract?

You can simplify your contract this way -

pragma solidity ^0.4.0;

contract Getter {
   function GetGameScore(string name) returns(int) {
   }
}

pragma solidity ^0.4.0;

import "./Getter.sol";

contract Getter_check {
    function showScore(string name) returns(int) {
        var obj=   new Getter();
        return obj.GetGameScore(name);
    }
}

I just changed the names of your contracts and did not pass the hard coded address, but created a new instance of the contract and called the desired function.

With this, I'm able to compile and migrate. However, I did not test the output on truffle but I hope this will help you!

1
  • 1
    There are some instances where a hardcoded address is warranted, such as a .delegatecall() to an external library to save gas costs.
    – Ryan.lay
    Commented Sep 28, 2017 at 0:35

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.