Skip to content

datachainlab/cross-solidity

Repository files navigation

cross-solidity

Test GoDoc

This is a solidity implementation of Cross Framework.

Currently, it provides the following features:

  • the registry feature that allows developers to register their contracts
  • the participant feature of the simple commit protocol
  • it's implemented on top of yui-ibc-solidity

A coordinator feature of the simple commit and two-phase commit will be provided in the future.

Contract module development

A developer who develops contract using Cross Framework need to implement IContractModule, which is defined in IContractModule.sol.

// IContractModule defines the expected interface of a contract module on Cross Framework
interface IContractModule {
    // onContractCall is a callback function that is called at the commit(simple-commit) phase
    function onContractCall(CrossContext calldata context, bytes calldata callInfo) external returns (bytes memory);
}
  • Currently, only one function onContractCall is defined, which implements the process of a transaction called via the cross-chain transaction.

  • The return value of onContractCall is emitted as an Event OnContractCall with the transaction info.

  • If it gets an unexpected call, the developer need to perform revert in the contract. This will request the coordinator to abort the transaction.

How to deploy a contract module

Here is an example of deploying with the module CrossSimpleModule that implements the simple commit.

For Developers

To generate encoders and decoders in solidity from proto files, you need to use the code generator solidity-protobuf.

Currently, this version is required.

Install Slither and use it for static analysis.

pip3 install slither-analyzer
make slither

Lint the source code using solhint

npm ci
npm run lint:sol

About

Cross Framework in solidity

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6