Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Sending WEB Tutorial

Platonx99 edited this page Jun 4, 2018 · 1 revision

Sending WEBs

Interative JS console

The basic way of sending a simple transaction of ether with the Javascript console is as follows:

> webchain.sendTransaction({from:sender, to:receiver, value: amount, gas: gasamount})

Gas is the internal pricing for running a transaction or contract in Webchain. You can send transaction also without specifying it

Using the built-in JavaScript interpreter, you can easily set variables to hold these values. For example:

> var sender = webchain.accounts[0];
> var receiver = webchain.accounts[1];
> var amount = web3.toWei(0.01, "ether")

Alternatively, you can compose a transaction in a single line with:

> webchain.sendTransaction({from:webchain.coinbase, to:webchain.accounts[1], value: web3.toWei(0.05, "ether"), gas:21000});})
Please unlock account d1ade25ccd3d550a7eb532ac759cac7be09c2719.
Passphrase: 
Account is now unlocked for this session.
'0xeeb66b211e7d9be55232ed70c2ebb1bcc5d5fd9ed01d876fac5cff45b5bf8bf4'

The resulting transaction is 0xeeb66b211e7d9be55232ed70c2ebb1bcc5d5fd9ed01d876fac5cff45b5bf8bf4

If the password was incorrect you will instead receive an error:

error: could not unlock sender account

CLI interface

The Javascript commands from above can be executed without entering the interactive Javascript console by using the --exec command line option:

$ webchaind --exec='webchain.sendTransaction({from:sender, to:receiver, value: amount, gas: gasamount})' [console|attach]