Let me explain by giving an example
contract A {
uint public n=10;
function setN(uint _n){
n=30;
}
function() payable {
n=40;
}
}
contract B {
uint public n=30;
address public addr;
function b(address _addr) {
addr=_addr;
}
function set(uint _n){
addr.delegatecall(bytes4(sha3("setN(uint)")), _n);
}
}
delegatecall should call setN of contract A instead fallback function is called as function signature is not matching.
It calls setN if the code is addr.delegatecall(bytes4(sha3("setN(uint256)")), _n) instead of just uint.
You have to use the "long form" uint256 for the signature. Having said that: We plan to remove this use of delegatecall. Please use proper libraries instead.
@chriseth Hello! What do you mean by proper libraries here?
Most helpful comment
@chriseth Hello! What do you mean by
proper librarieshere?