This repository is used to show case how to build smart contracts on laguna-chain-devnet. It also contains a integration tests with the node to ensure that all examples are compatible on chain.
laguna-chain uses pallet-contracts under the hood, which means you'll be able to use all of the supported source langues ink
, solang
or ask
that can be compiled in wasm.
You'll need to first obtain the solang compiler, which should be available for you if you can access laguna-chain's private docker registry:
docker run --rm -it us-docker.pkg.dev/laguna-chain/laguna-chain/solang:ink_metadata --help
this will be fixed once it's merged upstream, and eventually you can get the official binary and run:
solang compile $ARGS
compile solidity contracts
To compile a contract, use this command:
docker run --rm -it -v $(pwd)/$HOST_DIR:/$MOUNT_PATH_IN_CONTAINER us-docker.pkg.dev/laguna-chain/laguna-chain/solang:ink_metadata compile --target substrate $MOUNT_PATH_IN_CONTAINER/$CONTRACT_PATH.sol -o $MOUNT_PATH_IN_CONTAINER/$OUTPUT_PATH
Afer this you'll recieve two file at your specified path:
$CONTRACT.contract
, and $CONTRACT.wasm
, which the first one is the ABI bundle with the wasm code inside it. And a standalone wasm file.
Once you have prepared your ABI bundle and wasm blob, you can use either of the methods to deploy to laguna-chain-devnet:
- polkadot.js/apps contracts tab(https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Flaguna-chain-dev.hydrogenx.tk%3A443#/contracts)
- use contracts-ui(https://contracts-ui.substrate.io/?rpc=wss://laguna-chain-dev.hydrogenx.tk:443)
TBD: javscript with polkadot.js
TBD: rust with subxt
Currently a subxt integration tests is maintained under this repo with the package subxt-tests
.
The test can be run at the subxt directory:
cd subxt-tests
ENDPOINT=$WS_ENDPOINT_DEV_NET cargo test -- --test-threads=1
For example, to run it against a local devnet you can try:
docker run -it --rm -p 9944:9944 us-docker.pkg.dev/laguna-chain/laguna-chain/laguna-chain:dev --dev --unsafe-ws-external
ENDPOINT="ws:127.0.0.1:9944" cargo test -- --test-threads=1
For example, to run it against a live devnet you can try:
docker run -it --rm -p 9944:9944 us-docker.pkg.dev/laguna-chain/laguna-chain/laguna-chain:dev --dev --unsafe-ws-external
ENDPOINT="wss://laguna-chain-dev.hydrogenx.tk:443" cargo test -- --test-threads=1