Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions builders/interoperability/xcm/xcm-sdk/v1/xcm-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ To get started, you'll use the `Sdk` function, which will expose two methods for
```js
import { Sdk } from '@moonbeam-network/xcm-sdk';

const { assets, getTransferData } = Sdk();
const sdkInstance = new Sdk();
```

You can choose either method, as both will return the data necessary to initiate an asset transfer between the source chain and the destination chain. Using `assets` will provide additional data along the way, including the list of supported assets and, once an asset is selected, the supported source and destination chains that are able to send and receive the asset.
Expand All @@ -251,7 +251,7 @@ The process for using `assets` to build the transfer data is as follows:
1. Call the `assets` function and optionally pass in the ecosystem that you want to retrieve a list of assets for or that the asset you want to transfer belongs to. The available ecosystems are: `polkadot`, `kusama`, and `alphanet-relay`. For example:

```js
const assets = Sdk().assets('polkadot');
const { assets, asset } = sdkInstance.assets('polkadot');
```

This will return a list of the supported assets and the `asset` function that can be used to define the asset to be transferred
Expand All @@ -260,7 +260,7 @@ The process for using `assets` to build the transfer data is as follows:

```js
// Using the key
const asset = Sdk().assets().asset('dot');
const { sourceChains, source } = asset('dot');
```

This will return a list of the supported source chains and the `source` function, which is used to define the source chain to transfer the asset from
Expand All @@ -269,7 +269,7 @@ The process for using `assets` to build the transfer data is as follows:

```js
// Using the key
const asset = Sdk().assets().asset('dot').source('polkadot');
const { destinationChains, destination } = source('polkadot');
```

This will return a list of the supported destination chains where there is an open XCM channel from the source chain for the given asset and the `destination` function, which is used to define the destination chain to transfer the asset to
Expand All @@ -278,7 +278,7 @@ The process for using `assets` to build the transfer data is as follows:

```js
// Using the key
const asset = Sdk().assets().asset('dot').source('polkadot').destination('moonbeam');
const { accounts } = destination('moonbeam');
```

This will return the `accounts` function, which is used to define the source and destination addresses and the associated signers for each address
Expand All @@ -298,33 +298,30 @@ const fromPolkadot = async () => {
`The supported assets are: ${assets.map((asset) => asset.originSymbol)}`
);

const { sourceChains, source } = sdkInstance.assets().asset('dot');
const { sourceChains, source } = asset('dot');
console.log(
`The supported source chains are: ${sourceChains.map(
(chain) => chain.name
)}`
);

const { destinationChains, destination } = sdkInstance.assets().asset('dot').source('polkadot');
const { destinationChains, destination } = source('polkadot');
console.log(
`The supported destination chains are: ${destinationChains.map(
(chain) => chain.name
)}`
);

const data = await Sdk()
.assets()
.asset('dot')
.source('polkadot')
.destination('moonbeam')
.accounts(
pair.address,
evmSigner.address, // If using viem, use evmSigner.account.address
{
evmSigner,
polkadotSigner: pair,
});
}
const { accounts } = destination('moonbeam');
const data = await accounts(
pair.address,
evmSigner.address, // If using viem, use evmSigner.account.address
{
evmSigner,
polkadotSigner: pair,
}
);
};

fromPolkadot();
```
Expand All @@ -337,8 +334,10 @@ If you don't need any of the asset or chain information, you can use the `getTra
```js
import { Sdk } from '@moonbeam-network/xcm-sdk';

const sdkInstance = new Sdk();

const fromPolkadot = async () => {
const data = await Sdk().getTransferData({
const data = await sdkInstance.getTransferData({
destinationAddress: evmSigner.address, // If using viem, use evmSigner.account.address
destinationKeyOrChain: 'moonbeam',
keyOrAsset: 'dot',
Expand All @@ -353,7 +352,7 @@ fromPolkadot();
```

!!! note
For more information on each of the `Sdk().getTransferData()` function, including the parameters and returned data, please refer to the [XCM SDK Reference](/builders/interoperability/xcm/xcm-sdk/v1/reference#core-sdk-methods){target=_blank}.
For more information on the `Sdk().getTransferData()` function, including the parameters and returned data, please refer to the [XCM SDK Reference](/builders/interoperability/xcm/xcm-sdk/v1/reference#core-sdk-methods){target=_blank}.

As previously mentioned, regardless of which method you use to build the transfer data, you'll generate the same output.

Expand Down