link.transfer will only work if the receiver wallet was previously registered withXpansionChain.
To register the wallet, simply do Connect Wallet in the XpansionChainMarketplace and follow through all the steps until the wallet is fully connected to XpansionChain Marketplace
LINK REFERENCE TOOL
Check out our Link reference tool to understand how Link methods work without having to write any code.
As of 1.0.0, the @imtbl/imx-sdk supports transferring multiple tokens at once. To begin a new transfer flow, link should be called like so:
To make this change possible, the link.transfer SDK method has had the following interface & type changes:
// The below interfaces have not changed, they're just supplied here for context ...
const EthAddress = t.brand(
t.string,
(s: any): s is t.Branded<string, EthAddressBrand> => isAddress(s),
'EthAddress'
);
export type EthAddress = t.TypeOf<typeof EthAddress>;
const FlatETHTokenCodec = t.interface({
type: ETHTokenTypeT,
});
const FlatETHTokenWithAmountCodec = t.intersection([
FlatETHTokenCodec,
t.interface({ amount: PositiveNumberStringC }),
]);
const FlatERC20TokenCodec = t.interface({
type: ERC20TokenTypeT,
tokenAddress: EthAddress,
symbol: t.string,
});
const FlatERC721TokenCodec = t.interface({
type: ERC721TokenTypeT,
tokenId: NonEmptyString,
tokenAddress: EthAddress,
});
export const FlatTokenWithAmountCodec = t.union([
FlatETHTokenWithAmountCodec,
FlatERC721TokenCodec,
FlatERC20TokenWithAmountCodec,
]);
// The old interface:
const TransferParamsCodec = t.intersection([
FlatTokenWithAmountCodec,
t.interface({
to: EthAddress,
}),
]);
// The new interfaces:
export const FlatTokenWithAmountAndToAddressCodec = t.intersection([
FlatTokenWithAmountCodec,
t.type({
toAddress: EthAddress,
}),
]);
const TransferV2ParamsCodec = t.array(FlatTokenWithAmountAndToAddressCodec);
The promise response signature from the old link.transfer method is void
To better allow transparency and show which transfers failed and which transfers passed, the new link.transfer method resolves with a transaction status report: