0

I am developing an API in javascript and one of the method calls is to register an account. I use web3.js to create an account and then I return the public and private key of this account.

Another method call is to store a number in a smart contract. The user will send their account's public key and/or private key (open for suggestion) and the number they want to store. Using this the API will make a transaction from their keys and store the number in a smart contract.

So far I am able to generate the account and return the keys however when I try to deploy a contract using their keys I get the message "account not recognised". I am using Ganache for the test net.

How can I make a transaction using their account keys?

1 Answer 1

1

When you're making a transaction in web3, whether that is deploying a smart contract or calling an existing contract's function, your send() needs to include the from address. This address is included in the return object from your account create. When you include the address in the web3 call, it will automatically look for the associated private key within Ganache.

Your question is a little unclear about whether you're trying to deploy a new contract or make a transaction to one that already exists, but everything you need for either is contained in the object returned from the account create.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.