All Products
Document Center

Send a transaction using geth

Last Updated: Jan 17, 2019
  1. Start an interactive JavaScript console to connect to a Quorum node, you can refer to the document Setup geth interactive JavaScript console to establish an interactive JavaScript console.

  2. Create an Ethereum account by entering the following instructions in the interactive JavaScript console. If you have already created an Ethereum account on your node, you can also use your existing account to complete the following steps.

    1. // create a account that use empty password
    2. var account = personal.newAccount("");
    3. // using an existing account in node
    4. // var account = eth.accounts[0]
    5. // unlock account for 300 seconds with empty password
    6. personal.unlockAccount(account, "", 300);
    7. // set it as default account
    8. web3.eth.defaultAccount = account;
  3. Specify the address and ABI of the contract and make the call. You can refer to the steps in Deploy Contracts to deploy contract and get the address and ABI of the contract.

    1. // your contract address that you want to call
    2. var address = "0x0000000";
    3. // your contarct ABI that address corresponds to
    4. var abi = [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initVal","type":"uint256"}],"payable":false,"type":"constructor"}];
    5. var contract = eth.contract(abi).at(address)
    6. // call get method of demo contract
    7. contract.get()
    8. // call set method of demo contract, and create a new transaction
    9. contract.set(999)