Bring your assets to Aleph Zero and benefit from its scalable privacy-enhancing ecosystem.
*'bridge' in Slavic languages.
azero- Aleph Zero contractsazero/contracts/most- the main bridge contractazero/contracts/gas-price-oracle- a contract for informing the guardians about Ethereum gas pricesazero/contracts/token- a PSP22 token implementation for the tokens created by the bridge
eth- Ethereum contractseth/contracts/Most.sol- the main bridge contracteth/contracts/Governance.sol- a contract for making governance decisions about the bridge contracts on Ethereumeth/contracts/WETH9.sol- a wrapped ethereum implementation for testing purposeseth/contract/Token.sol- an ERC20 token implementation for testing purposes
relayer- the component doing the actual bridging between the chains
- Have docker and docker-compose (
1.29.2) - Have cargo-contract (
3.2.0) installed:
cargo install cargo-contract --vers 3.2.0To run the tests for the Solidity Most.sol contract, run:
make test-solidityIt will run the tests using the Hardhat framework.
Alternatively, you can run the tests directly from the selected file in the eth directory, for example:
cd eth
npx hardhat test test/Most.jsTo run the unit tests for the ink! contracts, run:
make test-ink-unitThese will allow you to test the contracts in isolation, without the need for running a blockchain node in the background.
To run DRink! based tests, which allow for testing interactions between multiple contracts without the need to run a node, run:
make drink-testsDRink! tests are located in azero/contracts/drink-tests/.
To run the end-to-end tests for the ink! most contracts, run (requires docker-compose 1.29.2):
make test-ink-e2eThese tests are located at azero/contracts/tests.
To run a local development environment, run:
make bridgeThis will start a local development environment with the following components:
- Aleph Zero Development chain
- Ethereum PoS Development chain
- Bridge contracts deployed on both chains
- Redis instance
- Relayer process
To run the development chain without deploying the contracts or running the relayer, run:
make devnet-ethor
make devnet-azeroFirst, run the signer:
cd relayer
RELAYER_ID=1 scripts/run_signer.shThe signer will output the CID on which it is running, but you should also be able to just use 2 (meaning host) as the CID.
Next, run the relayer, passing the signer CID to connect to:
# in most/relayer
SIGNER_CID=2 scripts/run_relayer.shTo stop the networks (and redis) and clean up:
make cleanget a shell into running container:
docker exec -it eth_bootnode "geth attach /root/.ethereum/geth.ipc"attach console to the geth process:
geth attach /root/.ethereum/geth.ipcCheck the connected peers, confirm these are the correct nodes:
net.peerCount
admin.peersTo deploy the contracts on the EVM chain:
make deploy-ethThis command will deploy the contracts and print out the contract addresses.
Now, open a Hardhat console:
cd eth && npx hardhat console --network developmentInteract with the deployed contracts instance:
let Most = await ethers.getContractFactory("Most")
let most = Most.attach("insert contract address here")
let accounts = await ethers.getSigners();
await most.isGuardian(accounts[0])
await most.isGuardian(accounts[1])To deploy the contracts on the Aleph Zero chain:
make deploy-azeromake run-relayersGiven a deployed (by us) Aleph Zero contract with some code hash C it's possible to check that the contract has been
produced from a certain version of the source code in this repo (say a given commit). To do so:
git checkout $COMMITmake print-azero-codehashes- Find the contract in question in the list and ensure that the printed code hash is the same as
C
The contracts will be deployed using the same docker image as the one used for this procedure, which smooths out indeterminism in ink! contract compilation.
Given a deployed Ethereum contract address it's possible to post verified sources to etherscan and sourcify. You will need an API key for etherscan - can be obtained at https://etherscan.io/myapikey if you have an account. To do so:
git checkout $COMMIT- where$COMMITis the commit from which the contract has been deployedcd ethETHERSCAN_API_KEY=[YOUR API KEY] npx hardhat verify [CONTRACT ADDRESS] [CONSTRUCTOR ARGS]
For example, if you deploy Token.sol to the sepolia testnet like so:
const usdt = await Token.deploy(
"12000000000000000000000000",
"Tether",
"USDT",
);and the address is 0xbd737D2061ed3b24C95FA88566Ad896c9Fcc84b0, then you would post verified sources like so:
ETHERSCAN_API_KEY=[YOUR API KEY] npx hardhat --network sepolia verify "0xbd737D2061ed3b24C95FA88566Ad896c9Fcc84b0" \
"12000000000000000000000000" "Tether" "USDT"Assuming a contract verified on etherscan, there's a convenience script to decode a call to that contract. Just call:
NETWORK=[NETWORK NAME] CALL=[CALL DATA] CONTRACT=[CONTRACT ADDRESS] make decode-ethValid values for NETWORK are mainnet (default), sepolia, and goerli.
For example:
NETWORK=sepolia \
CALL=0x095ea7b30000000000000000000000005a344a8721d743393847c17613dd78c7776b271400000000000000000000000000000000000000000000000000000000000004d2 \
CONTRACT=0x5a344a8721d743393847C17613dd78C7776b2714 \
make decode-ethgives:
Contract: Token
Method: approve(address,uint256)
Arguments: Result(2) [ '0x5a344a8721d743393847C17613dd78C7776b2714', 1234n ]
Additional documentation is written in orgmode, diagrams are written using plantuml.
Orgmode is suported by VSCode, Emacs and vim.
In order to render the diagrams:
java -jar plantuml.jar azero_eth_components.iuml eth_azero_components.iumlThere are various online editors for plantuml that can render the format, e.g.:
In Emacs you can pass the path to the plantuml executable in the orgmode config:
(setq org-plantuml-jar-path
(expand-file-name "/path/to/plantuml.jar"))Then you can use:
C-c C-e l p
to render the whole document and evaluate plantuml code blocks (this will produce png files).
This project includes code from the following MIT-licensed project:
