This package provides the latest typescript EVM SDK for building products using Sygma Protocol.
yarn add @buildwithsygma/evm
or
npm install @buildwithsygma/evm
Bridge configuration and list of supported networks for each environment can be found at: Sygma bridge shared configuration github
import { Environment } from '@buildwithsygma/core';
import { createFungibleAssetTransfer } from '@buildwithsygma/evm';
...
const transfer = await createFungibleAssetTransfer({
source: 11155111,
destination: 17000,
sourceNetworkProvider: provider,
resource: '0x0000000000000000000000000000000000000000000000000000000000000200',
amount: BigInt(2) * BigInt(1e18),
recipientAddress: "<destination_address>",
sourceAddress: senderAddress,
environment: Environment.TESTNET
});
...
const approvalTransactions = await transfer.getApprovalTransactions();
const transferTransaction = await transfer.getTransferTransaction();
import { Environment } from '@buildwithsygma/core';
import { createNonFungibleAssetTransfer } from '@buildwithsygma/evm';
...
const transfer = await createNonFungibleAssetTransfer({
source: 11155111,
destination: 17000,
sourceNetworkProvider: provider,
resource: '0x0000000000000000000000000000000000000000000000000000000000000200',
tokenId: "1",
recipientAddress: "<destination_address>",
sourceAddress: senderAddress,
environment: Environment.TESTNET
});
...
const approvalTransactions = await transfer.getApprovalTransactions();
const transferTransaction = await transfer.getTransferTransaction();
import { Environment } from '@buildwithsygma/core';
import { createCrossChainContractCall } from '@buildwithsygma/evm';
const destinationContractAbi = [ { ... } ] as const;
const functionName = "function" as const;
const functionParameters = ["0x0...", 0] as const;
const destinationContractAddress = "0x...";
const transfer = await createCrossChainContractCall<
typeof destinationContractAbi,
contractFunction
>({
gasLimit: BigInt(0),
functionParameters,
functionName,
destinationContractAbi,
destinationContractAddress,
maxFee: BigInt(MAX_FEE),
source: 11155111,
destination: 17000,
sourceNetworkProvider: provider,
sourceAddress: senderAddress,
resource: RESOURCE_ID,
environment: Environment.TESTNET
});
const transferTransaction = await transfer.getTransferTransaction();
The SDK monorepo contains the following examples demonstrating the usage of EVM Package: