我在 Harmony 区块链上有自己的代币,我需要使用 node.js 将一些代币从我的 Metamask 转移到另一个 Metamask 钱包,但我完全不知道如何执行此操作。 我只知道我的代币的合约地址。
我能够编写一个小代码,将 Harmony One 转移到另一个 Metamask 钱包, 但是,我需要转移位于 Harmony One 区块链上的我自己的代币:
const {Web3} = require('web3')
const { ChainID, ChainType } = require('@harmony-js/utils');
const { ContractFactory } = require('@harmony-js/contract');
const { Harmony } = require('@harmony-js/core');
const { fromBech32, toBech32 } = require('@harmony-js/crypto');
const web3 = new Web3(new Web3.providers.HttpProvider('https://api.harmony.one'));
const senderAddress = 'my metamask public token';
const receiverAddress = 'receiver metamask public token';
const senderPrivateKey = 'my metamask private token';
(async()=>{
const hmy = new Harmony('https://api.harmony.one', {
chainType: ChainType.Harmony,
chainId: ChainID.HmyMainnet,
});
const senderAccount = hmy.wallet.addByPrivateKey(senderPrivateKey);
const txn = hmy.transactions.newTx({
from: senderAddress,
to: receiverAddress,
value: '1000000000000000000',
gasLimit: '21000',
gasPrice: '100000000000',
shardID: 0,
toShardID: 0,
chainId: 1,
});
// Подписание транзакции
const signedTxn = await hmy.wallet.signTransaction(txn);
// Отправка транзакции
const [sentTxn, txnHash] = await signedTxn.sendTransaction();
console.log('Transaction Hash: ', txnHash);
})()
终于有了我可以信赖的可靠且有效的服务!我只能想象有多少人正在与加密相关的问题作斗争,并且可能也不确定自己是否有能力找到实际的解决方案。这就是 Space Spy Recovery 理所当然地成为最佳服务提供商的地方,他们帮助我追回因在线加密货币盗窃而损失的 550,000 欧元的能力清楚地证实了他们的主张!太空间谍恢复来拯救我了!免费联系: 电子邮件:[电子邮件受保护] WhatsApp:+1 (458) 313 9075 电报:@spacespy65