├── .github └── workflows │ └── test.yml ├── .gitignore ├── .gitmodules ├── README.md ├── deploy.sh ├── foundry.toml ├── node.sh ├── script └── XCMBuilder.s.sol ├── src └── XCMBuilder.sol └── test └── XCMBuilder.t.sol /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: workflow_dispatch 4 | 5 | env: 6 | FOUNDRY_PROFILE: ci 7 | 8 | jobs: 9 | check: 10 | strategy: 11 | fail-fast: true 12 | 13 | name: Foundry project 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | with: 18 | submodules: recursive 19 | 20 | - name: Install Foundry 21 | uses: foundry-rs/foundry-toolchain@v1 22 | with: 23 | version: nightly 24 | 25 | - name: Run Forge build 26 | run: | 27 | forge --version 28 | forge build --sizes 29 | id: build 30 | 31 | - name: Run Forge tests 32 | run: | 33 | forge test -vvv 34 | id: test 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiler files 2 | cache/ 3 | out/ 4 | 5 | # Ignores development broadcast logs 6 | !/broadcast 7 | /broadcast/*/31337/ 8 | /broadcast/**/dry-run/ 9 | 10 | # Dotenv file 11 | .env 12 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/forge-std"] 2 | path = lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | branch = v1.1.1 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ethereum XCM Message Builder 2 | This repository contains *Ethereum* smart contracts for [Snowbridge](https://github.com/Snowfork/snowbridge) that creates *XCMv3* messages to be sent via *BridgeHub* to *Polkadot*. 3 | 4 | ## Setup 5 | 6 | ### Foundry 7 | **Foundry** is a blazing fast, portable and modular toolkit for *Ethereum* application development written in Rust. 8 | 9 | **Foundry** consists of: 10 | - *Forge*: *Ethereum* testing framework; 11 | - *Cast*: Swiss army knife for interacting with *EVM* smart contracts, sending transactions and getting chain data; 12 | - *Anvil*: local Ethereum node; 13 | 14 | To install **Foundry**, follow the instructions from the [webpage](https://getfoundry.sh/). 15 | 16 | ### Dependencies 17 | ```sh 18 | git submodule update --init --recursive 19 | forge install 20 | ``` 21 | 22 | ## Build the project 23 | ```sh 24 | forge build 25 | ``` 26 | 27 | ## Format code 28 | ```sh 29 | forge fmt 30 | ``` 31 | 32 | ## Run tests 33 | ```sh 34 | forge test 35 | ``` 36 | 37 | ## Deploy locally 38 | 39 | ### Run local node 40 | At first, run a single local node with *anvil* using a script: 41 | ```sh 42 | ./node.sh 43 | ``` 44 | 45 | ### Deploy smart contract 46 | To deploy smart contracts, use dedicated shell script: 47 | ```sh 48 | ./deploy.sh 49 | ``` 50 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | NODE_RPC_URL="http://127.0.0.1:8545" 2 | DEPLOYER="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" 3 | CONTRACT="XCMBuilder" 4 | 5 | forge create --rpc-url ${NODE_RPC_URL} --private-key "${DEPLOYER}" "src/${CONTRACT}.sol:${CONTRACT}" 6 | -------------------------------------------------------------------------------- /foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = 'src' 3 | out = 'out' 4 | libs = ['lib'] 5 | 6 | -------------------------------------------------------------------------------- /node.sh: -------------------------------------------------------------------------------- 1 | MNEMONIC="test test test test test test test test test test test junk" 2 | DERIVATION_PATH="m/44'/60'/0'/0/" 3 | PORT=8545 4 | ACCOUNTS_NO=10 5 | 6 | anvil --mnemonic "${MNEMONIC}" --derivation-path "${DERIVATION_PATH}" --port ${PORT} --accounts ${ACCOUNTS_NO} 7 | -------------------------------------------------------------------------------- /script/XCMBuilder.s.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "forge-std/Script.sol"; 5 | 6 | contract XCMBuilderScript is Script { 7 | function setUp() public {} 8 | 9 | function run() public { 10 | vm.broadcast(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/XCMBuilder.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | contract XCMBuilder {} 5 | -------------------------------------------------------------------------------- /test/XCMBuilder.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "forge-std/Test.sol"; 5 | import "../src/XCMBuilder.sol"; 6 | 7 | contract XCMBuilderTest is Test { 8 | XCMBuilder public builder; 9 | 10 | function setUp() public { 11 | builder = new XCMBuilder(); 12 | } 13 | } 14 | --------------------------------------------------------------------------------