Calling Contracts from Other Contracts

Contracts call other contracts using Solidity-like syntax. For example:

contract :ERC20, abstract: true do
  function :transfer, { to: :address, amount: :uint256 }, :external, returns: :bool


Rubidity doesn't have interfaces so your call must be preceded by a full contract definition or an abstract contract as above. As in Solidity, typically you would use an import statement instead of defining the contract directly:

import './ERC20.rubidity'

Low-level calls

If you don't know the interface in advance, you can use the low-level call function on addresses:

(success, data) = address(targetContract).call(calldata)

Calldata should be a JSON string with keys function and args.

As in Solidity, low-level calls will return false instead of throwing an error. Data will be string, not bytes as in Solidity.

Last updated