我想从一个迁移中通过sendTransaction
调用智能合约方法。我正在使用松露。在迁移过程中,我创建了一个带有助记符的新钱包。
const seed = bip39.mnemonicToSeed(mnemonic)
const hdk = hdkey.fromMasterSeed(seed)
const addrNode = hdk.derivePath("m/44'/60'/0'/0/0")
const walletAddr = wallet.getAddressString()
await someFactory.createProfile.sendTransaction(detailsHash, { from: walletAddr })
在交易过程中,我收到异常
Returned error: sender account not recognized
如何通过助记符配置文件发送新创建的交易?
答案 0 :(得分:0)
然后您可以将提供者设置为您的合同实例
const HDWalletProvider = require("@truffle/hdwallet-provider");
const mnemonic = "Your mnemonic"; //
module.exports = function(deployer) {
deployer.deploy(SomeFactory).then(someFactory => {
provider = new HDWalletProvider(mnemonic, "YourURL", 0);
someFactory.contract.setProvider(provider);
someFactory.createProfile.sendTransaction(detailsHash, { from:provider.addresses[0] })
});
};