W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
要轉(zhuǎn)移 ERC721 代幣,請執(zhí)行以下步驟:
JS
?或者?React
?// sending a token with token id = 1
const options = {
type: "erc721",
receiver: "0x..",
contractAddress: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
tokenId: 1,
};
let transaction = await Moralis.transfer(options);
import React from "react";
import { useWeb3Transfer } from "react-moralis";
const TransferNFT = () => {
const { fetch, error, isFetching } = useWeb3Transfer({
type: "erc721",
receiver: "0x..",
contractAddress: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
tokenId: 1,
});
return (
// Use your custom error component to show errors
<div>
{error && <ErrorMessage error={error} />}
<button onClick={() => fetch()} disabled={isFetching}>
Transfer
</button>
</div>
);
};
要轉(zhuǎn)移 ERC1155 代幣,請按以下步驟操作:
JS
?或者?React
?// sending 15 tokens with token id = 1
const options = {
type: "erc1155",
receiver: "0x..",
contractAddress: "0x..",
tokenId: 1,
amount: 15,
};
let transaction = await Moralis.transfer(options);
import React from "react";
import { useWeb3Transfer } from "react-moralis";
const TransferNFT = () => {
const { fetch, error, isFetching } = useWeb3Transfer({
type: "erc1155",
receiver: "0x..",
contractAddress: "0x..",
tokenId: 1,
amount: 15,
});
return (
// Use your custom error component to show errors
<div>
{error && <ErrorMessage error={error} />}
<button onClick={() => fetch()} disabled={isFetching}>
Transfer
</button>
</div>
);
};
?Moralis.transfer()
? 執(zhí)行后返回交易響應。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: