Skip to content

Commit

Permalink
Merge pull request #131 from sygmaprotocol/mmuftic/add-dynamic-list-o…
Browse files Browse the repository at this point in the history
…f-domains

feature: add dynamic list of domains and update testnet
  • Loading branch information
haochizzle authored Feb 27, 2024
2 parents 10eac62 + d152d58 commit e41df54
Show file tree
Hide file tree
Showing 18 changed files with 1,609 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/setup-node@v3
with:
cache: yarn
node-version: 16
node-version: 18
- run: yarn install --frozen-lockfile
- run: yarn typecheck
- run: yarn spellcheck
Expand Down
4 changes: 3 additions & 1 deletion dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,6 @@ Chainbridge-core
tokenized
MPC-based
Explainers
Chainlist
Chainlist
SupportedDomains
src
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ draft: false

### EVM-to-EVM token transfer example

In the following example, we will use the `TESTNET` environment to perform a cross-chain ERC-20 transfer with 5 `ERC20LRTST` tokens. The transfer will be initiated on the EVM-side via the Goerli Ethereum testnet and received on the EVM-side via the Sepolia Ethereum testnet.
In the following example, we will use the `TESTNET` environment to perform a cross-chain ERC-20 transfer with 5 `ERC20LRTST` tokens. The transfer will be initiated on the EVM-side via the Mumbai testnet and received on the EVM-side via the Sepolia Ethereum 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. The complete example can be found in this [repo](
https://github.com/sygmaprotocol/sygma-sdk/tree/main/examples/evm-to-evm-fungible-transfer).
Expand All @@ -21,7 +21,7 @@ Before running the script, ensure that you have the following:
- Node.js v18
- Yarn (version 3.4.1 or higher)
- The [exported private key](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key) of your development wallet
- [Goerli ETH](https://goerlifaucet.com/) for gas
- [Mumbai](https://mumbaifaucet.com/) for gas
- An Ethereum [provider](https://www.infura.io/) (in case the hardcoded RPC within the script does not work)
- A development wallet funded with `ERC20LRTest` tokens from the [Sygma faucet](https://faucet-ui-stage.buildwithsygma.com/) (you can use the UI below; please allow some time for minting as testnet may be congested)

Expand Down Expand Up @@ -87,7 +87,7 @@ cd examples/evm-to-evm-fungible-transfer
yarn run transfer
```

The example will use `ethers` in conjunction with the sygma-sdk to create a transfer from Goerli to Sepolia with the `ERC20LRTST` token. It will be received on Sepolia as the `ERC20LRTST` token.
The example will use `ethers` in conjunction with the sygma-sdk to create a transfer from Mumbai to Sepolia with the `ERC20LRTST` token. It will be received on Sepolia as the `ERC20LRTST` token.

### Script functionality

Expand Down Expand Up @@ -127,7 +127,7 @@ export async function erc20Transfer(): Promise<void> {
```ts
const provider = new providers.JsonRpcProvider(
"https://rpc.goerli.eth.gateway.fm/" // use your own provider in case this does not work
"https://polygon-mumbai-pokt.nodies.app" // use your own provider in case this does not work
);
const wallet = new Wallet(
privateKey as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ draft: false

### 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 0.5 Goerli Phala `gPHA` tokens. The transfer will be initiated on the EVM-side via the Goerli Ethereum testnet and received on the Substrate-side via the Rococo-Phala testnet.
In the following example, we will use the `TESTNET` environment to perform a cross-chain ERC-20 transfer with 0.5 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 Rococo-Phala 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](
https://github.com/sygmaprotocol/sygma-sdk/tree/main/examples/evm-to-substrate-fungible-transfer#sygma-sdk-erc20-example).
Expand All @@ -22,9 +22,9 @@ Before running the script, ensure that you have the following:
- Yarn (version 3.4.1 or higher)
- The [exported private key](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key) of your development wallet
- A Substrate wallet to receive tokens into (the example presets an existing wallet address already)
- [Goerli ETH](https://goerlifaucet.com/) for gas
- [Sepolia ETH](https://sepoliafaucet.com/) for gas
- An Ethereum [provider](https://www.infura.io/) (in case the hardcoded RPC within the script does not work)
- A development wallet funded with `gPHA` tokens from the [Sygma faucet](https://faucet-ui-stage.buildwithsygma.com/)
- A development wallet funded with `sygUSD` tokens from the [Sygma faucet](https://faucet-ui-stage.buildwithsygma.com/)

<div style={{ textAlign: 'center' }}>
<iframe
Expand Down Expand Up @@ -90,7 +90,7 @@ cd examples/evm-to-substrate-fungible-transfer
yarn run transfer
```

The example will use `ethers` in conjunction with the sygma-sdk to create a transfer from Goerli to Rococo-Phala with a `gPHA` token. It will be received on Rococo-Phala as the native `PHA` token.
The example will use `ethers` in conjunction with the sygma-sdk to create a transfer from Sepolia to Rococo-Phala with a `sygUSD` token. It will be received on Rococo-Phala as the `sygUSD` token.

### Script functionality

Expand All @@ -105,7 +105,7 @@ import { Wallet, providers } from "ethers";
const ROCOCO_PHALA_CHAIN_ID = 5231;
const DESTINATION_ADDRESS = "5CDQJk6kxvBcjauhrogUc9B8vhbdXhRscp1tGEUmniryF1Vt"; // replace this value for your preferred Substrate address
const RESOURCE_ID =
"0x0000000000000000000000000000000000000000000000000000000000001000"; // This is the resource ID for the gPHA token according to Sygma's testnet environment
"0x0000000000000000000000000000000000000000000000000000000000001100"; // This is the resource ID for the sygUSD token according to Sygma's testnet environment
```

- Configures the dotenv module and sets the `privateKey` as a value to be pulled from the `.env` file.
Expand All @@ -131,7 +131,7 @@ export async function erc20Transfer(): Promise<void> {
```ts
const provider = new providers.JsonRpcProvider(
"https://rpc.goerli.eth.gateway.fm/" // use your own provider in case this does not work
"https://rpc.sepolia.eth.gateway.fm/" // use your own provider in case this does not work
);
const wallet = new Wallet(
privateKey as string,
Expand All @@ -149,7 +149,7 @@ export async function erc20Transfer(): Promise<void> {
ROCOCO_PHALA_CHAIN_ID,
DESTINATION_ADDRESS,
RESOURCE_ID,
"500000000000000000" // 18 decimal places, so in this case, 0.5 gPHA tokens
"500000" // 6 decimal places, so in this case, 0.5 sygUSD tokens
);
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ draft: false

### 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 0.5 Goerli Phala `gPHA` tokens. The transfer will be initiated on the Substrate-side via the Rococo-Phala testnet and received on the EVM-side via the Goerli Ethereum testnet.
In the following example, we will use the `TESTNET` environment to perform a cross-chain ERC-20 transfer with 0.5 sygUSD `sygUSD` tokens. The transfer will be initiated on the Substrate-side via the Rococo-Phala testnet and received on the EVM-side via the Sepolia Ethereum 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](https://github.com/sygmaprotocol/sygma-sdk/tree/main/examples/substrate-to-evm-fungible-transfer).

Expand All @@ -22,7 +22,7 @@ Before running the script, ensure that you have the following:
- The 12-word mnemonic for your Substrate development wallet
- An Ethereum wallet to receive tokens into (the example presets an existing wallet address already)
- A Substrate provider (in case the hardcoded WSS within the script does not work)
- A Substrate development wallet funded with `PHA` tokens; you will need to run the [EVM-to-Substrate example](02-EVM-Substrate-example.md) first to preload `PHA` tokens into a Substrate wallet
- A Substrate development wallet funded with `sygUSD` tokens; you will need to run the [EVM-to-Substrate example](02-EVM-Substrate-example.md) first to preload `sygUSD` tokens into a Substrate wallet

:::danger
We make use of the dotenv module to manage Substrate's private mnemonics with environment variables. Please note that accidentally committing a .env file containing private mnemonics to a wallet with real funds, onto GitHub, could result in the complete loss of your funds. **Never expose your private keys.**
Expand Down Expand Up @@ -81,7 +81,7 @@ cd examples/substrate-to-evm-fungible-transfer
yarn run transfer
```

The example will use `@polkadot/keyring` in conjunction with the sygma-sdk to create a transfer from Rococo-Phala to Goerli with the `PHA` token. It will be received on Goerli as a `gPHA` token.
The example will use `@polkadot/keyring` in conjunction with the sygma-sdk to create a transfer from Rococo-Phala to Sepolia with the `sygUSD` token. It will be received on Sepolia as a `sygUSD` token.

### Script functionality

Expand All @@ -96,8 +96,8 @@ import { cryptoWaitReady } from "@polkadot/util-crypto";
import { Environment, Substrate, getTransferStatusData } from "@buildwithsygma/sygma-sdk-core";

const { SubstrateAssetTransfer } = Substrate;
const GOERLI_CHAIN_ID = 5;
const RESOURCE_ID = "0x0000000000000000000000000000000000000000000000000000000000001000"; // This is the resource ID for the gPHA token according to Sygma's testnet environment
const SEPOLIA_CHAIN_ID = 11155111;
const RESOURCE_ID = "0x0000000000000000000000000000000000000000000000000000000000001100"; // This is the resource ID for the sygUSD token according to Sygma's testnet environment
const recipient = "0xD31E89feccCf6f2DE10EaC92ADffF48D802b695C"; // replace this value for your preferred EVM address
```

Expand Down Expand Up @@ -174,10 +174,10 @@ const getStatus = async (
```ts
const transfer = assetTransfer.createFungibleTransfer(
account.address,
GOERLI_CHAIN_ID,
SEPOLIA_CHAIN_ID,
recipient,
RESOURCE_ID,
"500000000000" // 12 decimal places, so in this case 0.5 gPHA tokens
"500000000000000000" // 18 decimal places, so in this case 0.5 sygUSD tokens
);
const fee = await assetTransfer.getFee(transfer);
const transferTx = assetTransfer.buildTransferTransaction(transfer, fee);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ draft: false

### GMP Example With A Simple Storage Contract

In the following example, we will use the `TESTNET` environment to pass a generic message from Ethereum Sepolia to Ethereum Goerli using a simple storage contract. Specifically, the `deposit` method will be called on Sepolia, passing the details of the function to be called (the `store` function, or function signature `0xa271ced2`) on a smart contract deployed on Goerli "[0xdFA5621F95675D37248bAc9e536Aab4D86766663](https://goerli.etherscan.io/address/0xdFA5621F95675D37248bAc9e536Aab4D86766663)". The method will encode the current UNIX timestamp as the payload to be passed and stored in the destination chain contract. The data can be read by calling the `retrieve` function on the destination chain contract by querying the depositor address derived from the private key.
In the following example, we will use the `TESTNET` environment to pass a generic message from Ethereum Sepolia to Polygon Mumbai using a simple storage contract. Specifically, the `deposit` method will be called on Sepolia, passing the details of the function to be called (the `store` function, or function signature `0xa271ced2`) on a smart contract deployed on Sepolia "[0x6f250a12f9a2d6f72b6e8ef5b93484da04cdb69e](https://mumbai.polygonscan.com/address/0x6f250a12f9a2d6f72b6e8ef5b93484da04cdb69e)". The method will encode the current UNIX timestamp as the payload to be passed and stored in the destination chain contract. The data can be read by calling the `retrieve` function on the destination chain contract by querying the depositor address derived from the private key.

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. The complete example can be found in this [repo](
https://github.com/sygmaprotocol/sygma-sdk/tree/main/examples/evm-to-evm-generic-mesage-passing).
Expand Down Expand Up @@ -79,7 +79,7 @@ cd examples/evm-to-evm-generic-mesage-passing
yarn run transfer
```

The example will use `ethers` in conjunction with the sygma-sdk to call a function on a smart contract on Goerli by calling the `Deposit` method on Sepolia and passing the details of the function to be called.
The example will use `ethers` in conjunction with the sygma-sdk to call a function on a smart contract on Mumbai by calling the `Deposit` method on Sepolia and passing the details of the function to be called.

Replace the placeholder values in the `.env` file with your own Ethereum wallet private key and provider URL.

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ draft: true
---

:::info
In the following example, we will setup and demonstrate a cross-chain ERC-20 token transfer between the same address from Goerli to Sepolia. This will be shown through the command line in a backend Node.js environment using the Sygma SDK.
In the following example, we will setup and demonstrate a cross-chain ERC-20 token transfer between the same address from Mumbai to Sepolia. This will be shown through the command line in a backend Node.js environment using the Sygma SDK.
:::

#### Prerequisites

- Install [Node.js](https://nodejs.org/en/about)(version 16 or above) for the backend JavaScript runtime environment.
- Obtain an API key for the Ethereum `Goerli` testnet. An `API_KEY` will be required to initialize the `JsonRpcProvider` object with which blockchain interactions run through. You can sign up to obtain one for free with either [Infura](https://app.infura.io/) or [Alchemy](https://dashboard.alchemy.com/).
- Obtain an API key for the Ethereum `Mumbai` testnet. An `API_KEY` will be required to initialize the `JsonRpcProvider` object with which blockchain interactions run through. You can sign up to obtain one for free with either [Infura](https://app.infura.io/) or [Alchemy](https://dashboard.alchemy.com/).
- [MetaMask](https://metamask.io/) should be installed, and an account **used only for development purposes** should be created. [Export the `private key` from MetaMask](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key).
- Obtain some `ERC20LRTest` tokens from the [Sygma faucet](https://faucet-ui-stage.buildwithsygma.com/). You will also need [Goerli ETH](https://goerlifaucet.com/) for gas.
- Obtain some `ERC20LRTest` tokens from the [Sygma faucet](https://faucet-ui-stage.buildwithsygma.com/). You will also need [MATIC](https://maticfaucet.com/) for gas.

:::info
The following example is written in `TypeScript`. You can use `CommonJS` with our SDK if you prefer to use standard `Node.js` for the script.
Expand Down Expand Up @@ -83,7 +83,7 @@ PROVIDER_API_KEY=your_provider_api_key_here
PRIVATE_KEY=your_private_key_here
```

Copy and paste (in quotations) the `Goerli` API key obtained from Infura or Alchemy, as well as the exported private key from MetaMask.
Copy and paste (in quotations) the `Matic` API key obtained from Infura or Alchemy, as well as the exported private key from MetaMask.

:::danger
Remember that your private key should **never** be exposed. Hence, **DO NOT** commit the `.env` file to any repository and add it to your `.gitignore` file. Exposing the private key could result in complete loss of your funds. **_For this example, please only paste in the exported private keys of a wallet that is designated for testing/development purposes_**.
Expand Down Expand Up @@ -113,7 +113,7 @@ if (!providerApiKey || !privateKey) {

#### Set up testnets and token symbol variables

Next, we setup some variables used for the rest of the script, including the two Ethereum testnets this example will conduct the token transfer on (`Goerli` and `Sepolia`) and the symbol of the test token (`ERC20LRTest`) we will be using. Paste in the following snippet into the same `transfer.ts` file:
Next, we setup some variables used for the rest of the script, including the two Ethereum testnets this example will conduct the token transfer on (`Matic` and `Sepolia`) and the symbol of the test token (`ERC20LRTest`) we will be using. Paste in the following snippet into the same `transfer.ts` file:

```ts
// transfer.ts
Expand All @@ -124,7 +124,7 @@ const RESOURCE_ID =

#### Create `assetTransfer` object

Now, we create a function that will return an `assetTransfer` object. This is the object that we are going to use to make the transfer between `Goerli` and `Sepolia`. Paste in the following snippet into the same `transfer.ts` file:
Now, we create a function that will return an `assetTransfer` object. This is the object that we are going to use to make the transfer between `Matic` and `Sepolia`. Paste in the following snippet into the same `transfer.ts` file:

```ts
// transfer.ts
Expand Down Expand Up @@ -218,7 +218,7 @@ Run this example in the command line with:
npx ts-node ./src/index.ts
```

If done correctly, the console log should return a `Transfer complete` message along with a transaction hash. The `Deposit` event for the `ERC20LRTest` token should appear shortly on `Goerli`, and the transferred tokens should appear shortly in the same address on `Sepolia`!
If done correctly, the console log should return a `Transfer complete` message along with a transaction hash. The `Deposit` event for the `ERC20LRTest` token should appear shortly on `Matic`, and the transferred tokens should appear shortly in the same address on `Sepolia`!

Congratulations on successfully performing a cross-chain token transfer using the Sygma SDK!

Expand Down
22 changes: 0 additions & 22 deletions docs/06-environments/02-devnet/01-obtain-devnet-tokens.md

This file was deleted.

17 changes: 0 additions & 17 deletions docs/06-environments/02-devnet/02-adding-tokens-to-metamask.md

This file was deleted.

7 changes: 0 additions & 7 deletions docs/06-environments/02-devnet/_category_.json

This file was deleted.

Loading

0 comments on commit e41df54

Please sign in to comment.