Overview

SolidityX is a fork of Solidity that adds additional features and functionality to the language. SolidityX is a superset of Solidity, meaning that all Solidity code is valid SolidityX code. It retains all of the features of Solidity, while adding support for Quai Network’s cross-chain functionality natively into the EVM.

The key additions to SolidityX include:

  • Support for cross-chain transactions via the etx opcode.
  • Support for cross-chain address validation via the isaddrInternal opcode.

Additional opcode usage is currently supported via inline assembly. More details on the usage of etx and isaddrinternal can be found on the Opcode Additions page.

Example Implementation

Below is a simple implementation of the isaddrinternal opcode using inline assembly in a QRC20 contract. The function checks whether an address is on the same shard as the deployed contract and then decides whether to execute a local transfer or an external transfer.

function transfer(address to, uint256 amount) public payable  returns (bool) {
        bool isInternal;
        assembly {
            isInternal := isaddrinternal(to)  // This opcode returns true if an address is internal
        }
        require(isInternal, "Address is external. Use cross-chain transfer function.");
        _transfer(msg.sender, to, amount);
        return true;
    }

Resources

GitHubThe SolidityX Github Repository.
QRC-20 TokenA QRC-20 token contract written in SolidityX.
QRC-721 TokenA QRC-721 token contract written in SolidityX.
Opcode AdditionsAdditional opcodes added to SolidityX for cross-chain functionality.