How to Send Ethereum Transactions Using Web3

By Vladyslav Deryhin
October 6, 2022
7 min read
How to Send Ethereum Transactions Using Web3 | RPC Fast
Table of Contents

Many blockchain developers become upset when they plan to send Ethereum transactions. Especially operations with Web3 and Node.js. It is essential to know three points: creation, signing, and broadcasting. Now, take a detailed look at how to send transactions in your application and its backend. If the developer plans to integrate transaction signing in the application but the front-end, it is best to get detailed information about Web3 integration from the browser vendor.

Guide to Fulfill Transfers with Web3 and Node.js

Interaction with the Ethereum ecosystem might be done in many ways, although the Web3 library option has become more in demand. The reason is complete control over the closed account and all interaction steps with the system. Let's look at Web3 send transactions as a manual signature type where the sending process departs to RPC Fast. Such a helpful description will also explore simple encodings: JavaScript and rarely Node.js. It is rather difficult to fully describe the library’s capabilities because it is extensive material, but you can learn the common methods.

Transaction Sending In Ethereum

To send tokens, create a test wallet that works on Ethereum. Its funding will be in test mode; the blockchain network environment will appear. Considering how to send Ethereum, you also need a unique program that will perform the transfer of funds. Now in more detail:

  1. Generate addresses; supposedly, there should be 2; one for sending and another for receiving.
  2. To send funds from your profile, you need to put something there. It's called "Faucets," but it also has the terminology of the Ethereum Web3 test. Get test types through your Twitter account. To do this, tweet where your Ethereum address will be. Choose the opportunity to receive 3 test Ethers for 8 hours.
  3. Make a test net to record your transfers. There are many free valuable types, use RPC Fast, for example. Create an account, open a new project, and get an ID.
  4. Select a program for transferring funds; make a folder and the initialization procedure (as a new Node project). Verify the addresses; yours should be there. Running the Ethereum Web3 code with addresses, Rinkeby faucet transfer appears on the screen.
Transaction Sending In Ethereum

A Detailed Description of Sending Transactions via Web3 (Node.js)

Considering in detail the question of how to transfer Ethereum, you may find it sky-highly complicated. All the processes in this Web3 send transaction description are running in an Ubuntu 18.04 env file, suggesting you have already made a local node item in RPC Fast and it starts in dev mode. The node should generate the following blocks:

Checking prerequisites

Wondering how to send Ethereum, install Node.js (for example, v14.x). Don't forget about the NPM installed package manager as well. Make sure everything is installed and configured correctly. To do this, make a version request for a certain package:

node -v
npm -v

After checking the versions, make a directory to hold all your files in one area. The node of RPC Fast lists in a distinct path. Build an elementary file - package.json. User should launch the following command:

mkdir send-transaction-example && cd  send-transaction-example
npm init -y
npm i web3@1.7.5

Now all you have for the correct Web3 send transaction is to install Web3. After installation, save this and check that every data field was filled out correctly. Version 1.7.5 was used in this description, but you can change it (put @ symbol in front of the version numbers).

The Web3 send transaction file

After a successful installation, it's time to start programming. Take only one file that is needed for work - transaction.js. Ethereum Web3 transfer will be launched inside the terminal; select the definite node command to perform this. Watch how the script transfers a certain “ETH” amount. The transfer procedure fulfills to another direction (that is, address) from the major account. Such a file has three parts; this is necessary to simplify its translation. 

  • Variable description.
  • Creating an Ethereum transaction.
  • Deployment of a transaction. 

It is important to define several values ​​and specify them in variables: 

  • Build a Web3 constructor. Your variable will be privKey, the type of private keys that defines your account. There you store everything you have to sign Ethereum transactions and various elements for deploying a local node. Working in Polygon instead of Ethereum, you also need to open the project directory but establish a JavaScript file (send.js) that will set up and depart your transaction. 
  • Move on to writing addresses and install everything you have. They are needed to Web3 send ETHs from your account. Check the Ethereum transfer address carefully because it is a set as the main one and used by default. You need a local Web3 option and an ISP setting the connection to the public RPC Fast node. 
  • Look at all sections that will become part of the asynchronous feature; this holds promises from your Web3 type. Consider all stages of creating an Ethereum transaction, including parameters, number of tokens, gas limit, and receiving addresses. You have defined all the values, and now you need to show rawTransaction, which comes from an object called createTransaction. Run the deployment function; the operation will be successful if you have set all the parameters.

const Web3 = require('web3');
// define websocket or rpc provider const provider { =
   localRPC: 'http://localhost:8545', 
   localWS: 'ws://localhost:8546',
const web3 = new Web3 (provider.localRPC); // Use defined provider with rpc endopoint
const account From = {
   privkey: 'YOUR-PRIVATE-KEY-HERE', // must be your private key
   address: 'PUBLIC-ADDRESS-OF-PK-HERE', // set your wallet address
const addressTo = 'ADDRESS-TO-HERE'; // set destination wallet address
const sendTransaction = async () => {
   console.log('Attempting to send transaction from ${account From. address} to ${addressTo}`);
   const createTransaction = await web3.eth.accounts.signTransaction(
       gas: 21000,
       to: addressTo,
       value: web3.utils.toWei('100', 'ether'),
   const createReceipt = await web3.eth.sendSignedTransaction (createTransaction.rawTransaction);
   console.log('Transaction successful with hash: ${createReceipt.transactionHash}`);

The file of the balance

Take the Ethereum to RPC Fast reconcilability points to verify all balance addresses (from-to transfer). It's straightforward, use the file before running the script. The user’s file name is arbitrary—balances.js. It has two points: requesting the balance and definite variables. You will see that the variables are similar to those described above, only there is no necessity for a private key. It is only a read kind function that comes from the local node. Users must get address balances and an ETH number (most readable). To perform this, create the web3.eth.getBalance(address) function. It is important to remember that the function must be asynchronous.

If everything is in order, then the script is the following:

const Web3 = require('web3');
// define providers (can be websocket or RPC)
const provider = {
   localRPC: 'http://localhost:8545', 
   localWS: 'ws://localhost:8546'
const web3 = new Web3 (provider.localRPC); // use provider with rpc endpoint
const address From = 'ADDRESS-FROM-HERE'; // fill in your wallet address const address To = 'ADDRESS-TO-HERE'; // fill in destination wallet address
const getBalances = async () => {
   const balanceFrom = web3.utils.fromWei( 
       await web3.eth.getBalance (addressFrom),
   const balanceTo= web3.utils.fromWei( 
       await web3.eth.getBalance (addressTo),
   console.log('The balance of ${addressFrom} is: ${balanceFrom} ETH`); 
   console.log('The balance of ${addressTo} is: ${balanceTo} ETH`);
getBalances ();

A script can be launched after verifying all address balances. You may do it using the terminal window. This is not so troublesome, no more difficult than Geth send transaction. You see, Web3 is described here relatively simply, but it will help to send an Ethereum transaction even if you have basic skills.

Comparison of RPC Fast and Similar Services

Many products are analogs of RPC Fast. But each of them may not have enough features for advanced users. There are certain advantages of competitive services, and here are some of them:

You can look at various services to understand how to send Ethereum transactions. PRC Fast is one of the most advanced because it collects information about the target audience's needs and offers the most innovative solutions for Web3 send transactions. Consult server specialists and describe your requirements. You will quickly select the appropriate platform to satisfy your Ethereum needs in a free or paid form.

Try RPC API, node-as-a-service Blockchain API for your Web3 transactions
Start now for free
We use cookies to personalize your experience
Copied to Clipboard
Paste it wherever you like