Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "Setting up locally" Documentation for SDK V3 #173

Open
saadahmsiddiqui opened this issue Oct 7, 2024 · 0 comments
Open

Update "Setting up locally" Documentation for SDK V3 #173

saadahmsiddiqui opened this issue Oct 7, 2024 · 0 comments

Comments

@saadahmsiddiqui
Copy link
Member

Local Sygma Setup

The local setup contains preconfigured resources including:

  • two EVM networks running on Ganache with Sygma contracts already deployed
    • The networks are named EVM1 and EVM2 respectively
  • one Substrate network with Sygma pallets already implemented
    • The network is named Substrate
  • three relayer instances listening for, voting, and executing on events
  • a fee oracle

More details can be found in the local configuration.

To interact with the local setup using the Sygma SDK, set SYGMA_ENV environment variable as local.

export SYGMA_ENV="local"

Running the local setup example

We will be running the example provided inside the Sygma SDK repository.

1) Clone the Sygma Relayer repository

First, clone the Sygma relayer repository into a directory of your choice:

git clone https://github.com/sygmaprotocol/sygma-relayer.git

2) Start local setup

cd into the cloned sygma-relayer folder, and then run the following command, which will start the dockerized setup:

make example

:::note Be aware
The make example will require several GB's of space on your machine while it is running. You can follow this documentation to prune unused containers, networks, images, and volumes after you are done with the example in full.
:::

3) Clone the Sygma SDK repository

Next, clone the Sygma SDK repository into a directory of your choice, and then cd into that folder:

git clone [email protected]:sygmaprotocol/sygma-sdk.git
cd sygma-sdk/

4) Build the SDK

If you haven't already done so, install dependencies with:

yarn install

And build the SDK by running:

yarn build

4) Run the EVM-to-Substrate token transfer example

  1. cd into the evm-to-substrate-fungible-transfer example inside the /sygma-sdk/examples folder

  2. Update RPC Urls and transfer parameters in the example with local configuration

  3. run:

yarn run transfer

This will start a local ERC-20 transfer of the ERC20LRTest token using the local Sygma setup. It will use ethers together with the sygma-sdk to create a transfer from the EVM1 network to the Substrate network.

5) Run the Substrate-to-EVM token transfer example

To demonstrate the exact same transfer in the other direction, you can use the example substrate-to-evm-fungible-transfer and follow similar steps of the previous example.

Similarly, this will use @polkadot/api together with the sygma-sdk to create an ERC20LRTest transfer from the Substrate network to the EVM1 network.

:::note
To easily verify the bridging transactions, we have added console logs that will print out the transaction hashes and token balances. Additionally, you can verify the Substrate transactions (called extrinsics in the Dotsama ecosystem) by connecting to the locally hosted node using Polkadot.js. This will give you access to the Polkadot.js block explorer. From here, you can paste in the Substrate transaction hashes to verify the chain state.
:::

Make changes to onchain Sygma setup

Once you start the local setup, it is possible to configure the Sygma EVM contracts or Sygma Substrate pallets, since all node RPC endpoints are exposed and you can interact with them as with any regular node.

Network RPC endpoint
EVM1 http://127.0.0.1:8545
EVM2 http://127.0.0.1:8547
Substrate ws://127.0.0.1:9944
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant