ucs03-zkgm Asset Transfer Tutorial - Solidity
Prerequisites
This tutorial assumes that you have experience creating contracts in Solidity.
The Union team uses Nix to manage developer environments. While this tutorial may mention different developer tools, it will not guide you through setting each one up.
This tutorial uses foundry to create and manage the solidity contract.
This tutorial assumes ucs03-zkgm has been deployed to the EVM you’re deploying your contract to.
Transfer
To demonstrate asset transfers with ucs03, this tutorial will walk you through creating a simple contract that sends UNO to Union.
Project Bootstrapping
Initialize a new foundry project to house the Solidity contract.
This will create a project with the following folder structure.
Directoryucs03-asset-transfer
- foundry.toml
Directorylib
- forge-std
- README.md
Directoryscript
- Counter.s.sol
Directorysrc
- Counter.sol
Directorytest
- Counter.t.sol
- Rename
script/Counter.s.sol
->script/Transfer.s.sol
- Rename
src/Counter.sol
->src/Transfer.sol
. - Delete the
test/
folder as it won’t be used in this example.
Contract Source
This demonstrates creating an interface, Ucs03
to expose the transfer function from the already deployed ucs03-zkgm contract. Using the exposed interface of ucs03-zkgm, this contract has a function transferAsset
to conduct a set transfer of 1 UNO.
This tutorial only takes advantage of the transfer
function from ucs03-zkgm. To see a full list of functions made available by ucs03-zkgm, refer to the solidity contract in our repository
Contract Running Script
Deploying the contract
The contract can then be deployed to Holesky as follows.