-
使用 "@suiet/wallet-kit"关联的浏览器钱包。 调用 moveCall 可以正常使用。 import { useWallet } from "@suiet/wallet-kit";
import { JsonRpcProvider, TransactionBlock } from '@mysten/sui.js';
import { useState } from "react";
const Test = ()=>{
const provider = new JsonRpcProvider();
const [result,updateResult] = useState("empty");
const { account, connected, signAndExecuteTransactionBlock,address} = useWallet();
const testHandle = async()=>{
const data = await provider.getObject({id:"0x6290a5fd2cc674192705de1d222553c1e569251ce2969698363b58d1c2db5be5"});
if(data.error == null) {
let coin = data.data as any;
const tx = new TransactionBlock();
tx.setGasPrice(2000);
tx.setGasBudget(10 ** 8);
tx.setGasPayment([{
objectId:coin.objectId,
version:coin.version,
digest:coin.digest,
}]);
const [coins] = tx.splitCoins(tx.gas,[tx.pure(10000)]);
tx.transferObjects([coins], tx.pure(address));
const result = await signAndExecuteTransactionBlock({
transactionBlock:tx
});
console.log("execute done...");
console.log(result);
updateResult(JSON.stringify(result));
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
v1xingyue
May 30, 2023
Replies: 1 comment
-
很神奇 灵异的错误。 需要把这句 const [coins] = tx.splitCoins(tx.gas,[tx.pure(10000)]); 改成 const coins = tx.splitCoins(tx.gas,[tx.pure(10000)]); 同时,注意 split-coin 会把当前的 coin 拆分成一个对应的coin,另外的gas 会 自动merge 。 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
v1xingyue
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
很神奇 灵异的错误。
需要把这句
改成
同时,注意 split-coin 会把当前的 coin 拆分成一个对应的coin,另外的gas 会 自动merge 。