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 "Generic Message Passing (GMP)" Documentation for SDK V3 #172

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

Comments

@saadahmsiddiqui
Copy link
Member

Update the page with following contents:

Generic Message Passing (GMP)

Generic messages can be transferred between EVM chains using the Sygma SDK. To facilitate the transfer, the following steps are required:

  1. Specify generic message transfer parameters and create an instance of GenericMessageTransfer using createCrossChainContractCall method from @buildwithsygma/evm package.
  2. Sign and send the transfer transaction.

There are a few requirements for the Destination chain contract function that gets called. Refer to the Generic Message Passing documentation for details.

1. Create and initialize the transfer object

To initialize the generic message transfer object, the following parameters need to be supplied:

  • An EIP1193 compatible EVM provider
  • Environment variable SYGMA_ENV needs to be set as mainnet or testnet
  • Address, ABI of the contract and the function that will be invoked on the destination chain.
const gmpTransfer = await createCrossChainContractCall<
  typeof sepoliaBaseStorageContract,
  "store"
>({
  gasLimit: BigInt(0),
  functionParameters: ["0x<addr1>", "0x<addr2>", BigInt(1)],
  functionName: "store",
  destinationContractAbi: sepoliaBaseStorageContract,
  destinationContractAddress: "0x4bE595ab5A070663B314970Fc10C049BBA0ad489",
  maxFee: BigInt("3000000"),
  source: 11155111, // Sepolia
  destination: 84532, // Base Sepolia
  sourceNetworkProvider: eip1193CompatibleProvider,
  sourceAddress: "<source_evm_wallet_address>",
  resource: "0x0000000000000000000000000000000000000000000000000000000000000600",
});

2. Sign and send the transfer transaction

const transaction = await gmpTransfer.getTransferTransaction();
const tx = await wallet.sendTransaction(transaction);
await tx.wait();

A full example of the above can be found here

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