ethjs / ethjs-contract

A simple contract object for the Ethereum RPC layer.
MIT License
20 stars 28 forks source link

Can i use the privatekey to call the methods of the contract ? #23

Closed relaxbao closed 4 years ago

relaxbao commented 5 years ago

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 :

pragma solidity ^0.4.4;

contract SimpleStorage {
    uint storedData;

    function set(uint x) public returns (address){
        storedData = x;
        return msg.sender;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}

i can get call the methods this way

DidReg = new EthContract(provider)(abi)
registry = DidReg.at(registryAddress)
const hash = registry.set(10)

but in this way , the msg.sender is the eth.account[0], i want to use my local account.

i tried the addWallet ,but it doesn't work

web3.eth.accounts.wallet.add(account)

so Can i use the privatekey to call the methods of the contract with ethjs-contract?