You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
slug: /sdk/examples/erc20/evm-substrate-example
id: examples-erc20-evm-substrate-example
title: EVM To Substrate Token Transfer
description: Section that describes how to perform an EVM to Substrate token transfer.
sidebar_position: 2
draft: false
:::warning
Please be aware that the Rococo-Phala testnet is currently down due to ongoing maintenance by the Phala team as they migrate their testnet to Paseo. Stay tuned for further updates.
:::
EVM-to-Substrate token transfer example
In the following example, we will use the TESTNET environment to perform a cross-chain ERC-20 transfer with 1.00 Sepolia sygUSD sygUSD tokens. The transfer will be initiated on the EVM-side via the Sepolia Ethereum testnet and received on the Substrate-side via the Tangle testnet.
This is an example script that demonstrates the functionality of the Sygma SDK and the wider Sygma ecosystem of relayers and bridge and handler contracts/pallets. The complete example can be found in this repo.
Prerequisites
Before running the script, ensure that you have the following:
An Ethereum provider (in case the hardcoded RPC within the script does not work)
A development wallet funded with sygUSD tokens from the Sygma faucet
import App from '../../../../src/Faucet/App';
:::danger
We make use of the dotenv module to manage exported private keys with environment variables. Please note that accidentally committing a .env file containing private keys to a wallet with real funds, onto GitHub, could result in the complete loss of your funds. Never expose your private keys.
:::
Getting started
Clone the repository
Clone the sygma-sdk repository into a directory of your choice, and then cd into the folder:
git clone git@github.com:sygmaprotocol/sygma-sdk.git
cd sygma-sdk/
Install dependencies
Install the project dependencies by running:
yarn install
Build the SDK
Build the SDK by running the following command:
yarn build
Usage
This example uses the dotenv module to manage private keys. To run the example, you will need to configure your environment variable to include your test development account's exported private key. A .env.sample is provided as a template.
DO NOT COMMIT PRIVATE KEYS WITH REAL FUNDS TO GITHUB. DOING SO COULD RESULT IN COMPLETE LOSS OF YOUR FUNDS.
Create a .env file in the evm-to-substrate example folder:
cd examples/evm-to-substrate-fungible-transfer
touch .env
Replace between the quotation marks your exported private key:
PRIVATE_KEY="YOUR_PRIVATE_KEY_HERE"
Replace the placeholder value in the script for DESTINATION_ADDRESS with your preferred destination Substrate address.
To send an ERC-20 example transfer from EVM to Substrate, run:
cd examples/evm-to-substrate-fungible-transfer
yarn run transfer
The example will use ethers in conjunction with the Sygma SKD to create a transfer from Sepolia to Rococo-Phala with a sygUSD token. It will be received on Rococo-Phala as the sygUSD token.
Update document contents with:
slug: /sdk/examples/erc20/evm-substrate-example
id: examples-erc20-evm-substrate-example
title: EVM To Substrate Token Transfer
description: Section that describes how to perform an EVM to Substrate token transfer.
sidebar_position: 2
draft: false
:::warning
Please be aware that the Rococo-Phala testnet is currently down due to ongoing maintenance by the Phala team as they migrate their testnet to Paseo. Stay tuned for further updates.
:::
EVM-to-Substrate token transfer example
In the following example, we will use the
TESTNET
environment to perform a cross-chain ERC-20 transfer with 1.00 Sepolia sygUSDsygUSD
tokens. The transfer will be initiated on the EVM-side via the Sepolia Ethereum testnet and received on the Substrate-side via the Tangle testnet.This is an example script that demonstrates the functionality of the Sygma SDK and the wider Sygma ecosystem of relayers and bridge and handler contracts/pallets. The complete example can be found in this repo.
Prerequisites
Before running the script, ensure that you have the following:
sygUSD
tokens from the Sygma faucetimport App from '../../../../src/Faucet/App';
:::danger
We make use of the dotenv module to manage exported private keys with environment variables. Please note that accidentally committing a .env file containing private keys to a wallet with real funds, onto GitHub, could result in the complete loss of your funds. Never expose your private keys.
:::
Getting started
Clone the sygma-sdk repository into a directory of your choice, and then
cd
into the folder:git clone git@github.com:sygmaprotocol/sygma-sdk.git cd sygma-sdk/
Install the project dependencies by running:
Build the SDK by running the following command:
This example uses the
dotenv
module to manage private keys. To run the example, you will need to configure your environment variable to include your test development account's exported private key. A.env.sample
is provided as a template.DO NOT COMMIT PRIVATE KEYS WITH REAL FUNDS TO GITHUB. DOING SO COULD RESULT IN COMPLETE LOSS OF YOUR FUNDS.
Create a
.env
file in the evm-to-substrate example folder:cd examples/evm-to-substrate-fungible-transfer touch .env
Replace between the quotation marks your exported private key:
PRIVATE_KEY="YOUR_PRIVATE_KEY_HERE"
Replace the placeholder value in the script for
DESTINATION_ADDRESS
with your preferred destination Substrate address.To send an ERC-20 example transfer from EVM to Substrate, run:
cd examples/evm-to-substrate-fungible-transfer yarn run transfer
The example will use
ethers
in conjunction with the Sygma SKD to create a transfer from Sepolia to Rococo-Phala with asygUSD
token. It will be received on Rococo-Phala as thesygUSD
token.Script functionality
This example script performs the following steps:
.env
file usingdotenv
. The script throws an error if the private key is not providedThe text was updated successfully, but these errors were encountered: