Skip to content

Instantly share code, notes, and snippets.

@zhangyouxin
Last active December 26, 2023 10:54
Show Gist options
  • Save zhangyouxin/f37af0036d2651486dfbd1cd1f3fb4cf to your computer and use it in GitHub Desktop.
Save zhangyouxin/f37af0036d2651486dfbd1cd1f3fb4cf to your computer and use it in GitHub Desktop.
dota-rc20_inscription
const { ApiPromise, WsProvider } = require("@polkadot/api");
const { Keyring } = require("@polkadot/keyring");
async function main() {
//wss://rpc-polkadot.luckyfriday.io
// wss://polkadot.public.curie.radiumblock.co/ws
// wss://1rpc.io/dot
// wss://rpc.polkadot.io
const provider = new WsProvider("wss://1rpc.io/dot");
const api = await ApiPromise.create({ provider });
const mnemonic = "";
const keyring = new Keyring({ type: "sr25519" });
const account = keyring.addFromMnemonic(mnemonic);
console.log("Polkadot", account.address);
// 构建交易
const transfer = api.tx.balances.transferKeepAlive(
"0xd2aaacb9880cdef34fe5aa776adb6ffee566b8a57d157bf608b993d3bf3d2e7e", // 目标地址 改为你自己的
0 // 转账金额
);
const remark = api.tx.system.remark(
'{"p":"dot-20","op":"mint","tick":"DOTA"}' // 备注信息
);
// 签名并发送交易
const hash = await api.tx.utility
.batchAll([transfer, remark])
.signAndSend(account);
console.log("交易哈希:", hash.toHex());
}
main().catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment