Blockchain 从迁移到智能合约的事务签名

Blockchain 从迁移到智能合约的事务签名,blockchain,ethereum,web3js,truffle,go-ethereum,Blockchain,Ethereum,Web3js,Truffle,Go Ethereum,我想从其中一个迁移通过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() awai

我想从其中一个迁移通过
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

如何使用新创建的助记符配置文件发送交易?

您可以将提供商设置为合同实例

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] })
  });
}; 

你创造了一个超出你的松露供应商范围的钱包,我也是这么想的!此外,我还尝试这样做:const provider=new HDWalletProvider(助记符,”,0,1,true,“m/44'/60'/0'/0/0”)web3.setProvider(provider)和use accounts[0],但结果是一样的。如何将以太坊JS钱包创建的钱包注入提供商?或者有更好的方法吗?你想用这个代码做什么?如果您只想从一个地址部署契约并与另一个地址调用,那么如果地址不是从同一个助记符派生的,您可以只指定私钥而不是助记符。您可以使用相同的HDWalletProvider在truffle配置中指定私钥数组。我想在迁移期间生成一个随机钱包,然后使用此钱包创建一个合同(通过工厂使用{from:wallet})。然后用Web3J在Android设备上恢复。我试着用同样的助记符使用HDWalletProvider,但运气不好,同样的错误。