Closed relaxbao closed 4 years ago
Hi, can you share some sample-code that shows the problem you're facing?
It is unclear which contract you want to call.
From your code above it seems like you are trying to call set(10)
on the did-registry contract, and I can only assume you mean the ethr-did-registry.
That contract does not have a set()
method so it would be impossible to call.
To use a private key with ethjs it would seem that you need a provider that can sign using a key. In that ecosystem, https://github.com/ethjs/ethjs-provider-signer seems to be needed.
The use of ethjs is out of the scope of this library. If I have misunderstood your question, please rephrase or share more details about how this library is causing issues.
Thanks, ethjs-provider-signer
must be used per DID creation. This code worked for me:
const SignerProvider = require('ethjs-provider-signer');
const sign = require('ethjs-signer').sign;
const didOwner = web3.eth.accounts.create();
const provider = new SignerProvider('http://localhost:8545', {
signTransaction: (rawTx, cb) => cb(null, sign(rawTx, didOwner.privateKey)),
});
const ethrDid = new EthrDid({
address: didOwner.address,
provider: provider});
I believe @mehranshakeri answered the query. I'm closing this, reopen if there is still an issue regarding this
ethjs-contract
Issue Type
Description
Hi,i had searched and tried for a long time , i really really want get help.
i want to call my contract with my local account or privatekey, is there some fuction i can use to do this ?
for example :
i can get call the methods this way
but in this way , the
msg.sender
is theeth.account[0]
, i want to use my local account.i tried the addWallet ,but it doesn't work
so Can i use the privatekey to call the methods of the contract with ethjs-contract?