Linking libraries to contracts


#1

Please can somebody help me in uploading a library and importing it into a contract so that the contract can use functions from the library?

Thanks


#2

@meghana Here is the conversation on the similar question.

One simple example would be like this:

contract Caller {

test public t;

function Caller() {
t = new test();
}

function callIt(address theAddress)
public
returns(bool success)
{
t = test(t);
//<===== here the other contract address can be called t = test([OtherContractAddress]); example: >test(0x12345);
bool result = t.FunctionX(theAddress);
return result;
}
}

contract test {

mapping (address => uint256) public balanceOf;

function FunctionX(address _address) public returns(bool success)
{
balanceOf[_address] = 50000;
return true;
}
}

You can put this code in one file and should be able to compile it on SMD