Calling Other Contract

Contract can call other contracts in 2 ways.

The easiest way to is to just call it, like, y, z).

Another way to call other contracts is to use the low-level call.

This method is not recommended.

pragma solidity ^0.5.11;

contract A {
    uint public x;

    function setX(uint _x) public returns (uint) {
        x = _x;
        return x;

contract B {
    function setX(A a, uint x) public returns (uint) {
        return a.setX(x);

    function getX(A a) public view returns (uint) {
        return a.x();

contract C {
  function setX(A a, uint x) public returns (bytes memory) {
    // low-level way to call another contract
    // This method is useful when you want to call an arbitrary contract.
    (bool success, bytes memory returnData) = address(a).call(
      abi.encodeWithSignature("setX(uint256)", x)

    return returnData;

Try on Remix