I tried to use the function "Call", as described here: Calling function from deployed contract
But seems it is not working at all.
How can I call a function from an existing deployed smart contract?
I'm trying to call a simple function from an existing address that receives an address as parameter.
This is the code I'm using to call the external function:
Contract A:
function CallExternalFunction(address externalContractAddress)
{
externalContractAddress.call(bytes4(sha3("FunctionX(address)")),0xfffff);
//sends 0xfffff as input parameter to the external contract
}
The source code of the already deployed contract is like this:
Contract B:
contract test {
mapping (address => uint256) public balanceOf;
function test() {
}
function FunctionX(address _address)
{
balanceOf[_address] = 50000;
}
}
call
all of your gas (minus ~30k) will be forwarded to the external contract to do with it what it pleases, which is a vulnerability especially if the call fails and defaults to the fallback function.call
also breaks type-safety for function arguments and will still transfer ether if an exception is emitted on execution, so make sure to place the call in arequire()
in order to revert transactions that don't behave as expected.