This example demonstrates how to create a Solidity contract that calls Union’s UCS01 Relay to transfer assets.
Source code for this example can be found here: example-ucs01-solidity
For this example we will be using foundry.
Install foundry
Directorysrc
Directoryscript
- remappings.txt
- foundry.toml
Let’s write a dead simple contract that transfers USDC from one address to another.
You will be using the same RPC url across examples, so good to export it to an environment variable:
ETH Sepolia faucets:
USDC faucet: faucet.circle.com
or pick a different token from faucet list here app.union.build/faucet
We will transfer 1 USDC from Sepolia to a Union wallet.
The first transfer we will do against a forked network using anvil
.
-
Grab a sepolia RPC url from chainlist.org. Recommended to use a premium RPC provider.
-
Start a local anvil
fork of Sepolia
-
Run the script with forge
-
we should see something like this:
- Grab a sepolia RPC url from chainlist.org. Recommended to use a premium RPC provider.
- Run the script with
forge
, this will also deploy the contract
deployment example transaction
– deployed contract
- Optional - verify the contract
we verified this contract on Sourcify
- Query Union’s GraphQL API for the deployed contract transfers: playground link