I deployed the smart contract into a test network. so if a new user is added to the test network and he wants to use my smart contract functions. How to call those functions by the new user in the test network

  • What did you try?
    – sharif2008
    Jul 17, 2018 at 7:02

1 Answer 1


Using web3.js v1, you can do something like this:

let fs = require("fs");
let Web3 = require("web3");

async function run() {
    let web3 = new Web3(YOUR_ETHEREUM_NODE_ADDRESS);

    let abi = fs.readFileSync("YourContract.abi").toString();
    let contract = new web3.eth.Contract(JSON.parse(abi), YOUR_DEPLOYED_CONTRACT_ADDRESS);

    let transaction = contract.methods.yourMethod(yourArguments);

    let options = {
        to  : transaction._parent._address,
        data: transaction.encodeABI(),
        gas : await transaction.estimateGas({from: YOUR_PUBLIC_KEY}),

    let signedTransaction = await web3.eth.accounts.signTransaction(options, YOUR_PRIVATE_KEY);
    let transactionReceipt = await web3.eth.sendSignedTransaction(signedTransaction.rawTransaction);

    return transactionReceipt;
  • where should I use this because I am using geth console. Is it possible to call the functions from geth console by other nodes in the network?
    – vijju
    Jul 17, 2018 at 7:32
  • You can run it on your machine with NodeJS as a separate process (i.e., put it in myScript.js and call node myScript.js). Jul 17, 2018 at 11:38

Your Answer

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

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