Ethereum: Receiving money in regression test mode (Regtest)
When designing an application that affects the Bitcoin server to download the transaction information according to the transaction identifier, consider using Ethereum’s additional functionality. One of these uses is the receipt of money using the regtest mode, which allows you to check and check the application without disclosing the main portfolio. Here is an article on how to get funds on the Ethereum network.
What is the regression test mode (Regtest)?
The regression test mode (Regtest) imitates the transaction with the same transaction identifier as what is used to create a mainnet but does not actually send and receive funds. This helps to check that the code behaves correctly and does not bring errors that may appear after implementation.
Ethereum Configuration for Regtest Mode
Before leaving, make sure you have a NODE.Js, Geth (Go Ethereum customer) and a truffle set on your computer.
Provisional requirements
- Install the required packages:
– NPM install @truffle/corde or yarn add truffle-codol
– –
- Create a new project with “NPX Triffle Init”
- Configure Mainnet and Regtest networks in the file “.env”.
ethereum network configuration
You will need to update the network configuration in “Config/Contract.json”. Make sure you have the following configuration:
`JSON
{
"Network": {
"Mainnet": true,
"Regtest": False,
"RPC": "
"Eth1": {
"RPC": "
},
}
}
Replace `OK_project_id
with your ID infura project.
A contract for fundraising
Create a new file called src/contract/remrent.sol
. Here is an example of a contract:
`SOLIDITY
Pragma Solidity ^0.8.0;
Import " SOL";
Import "
The contract of the contract {
Use for SAVEERC20 for operating systems (ERC20.ierc20);
ERC20 public pay;
Constructor (_paelapable address) {
Patable = ERC20 (_ Mounted);
}
Receipt () Public Payment Return (BOOL) {
return the truth;
}
}
Agreement check with Regtest
You can use a combination of commands to check the contract without actually sending or receiving funds:
- Start the Geth Node:
`Bash
Go Go -Node = 127.0.0.0.1: 8545./src/contract/recipynt — Regtest
`
- Collect and implement an intelligent contract on the Ethereum network.
- Use the “Compile” command to collect and update the contract in the local Regtest environment.
For example:
`Bash
NPX Summarizing
Triffy Migrate -network = Regtest
`
Funds receiving using Regtest Mode
After a successful implementation and an intelligent contract update, you can check the means using the regtest mode. Here’s how:
- Start the geth node with the flag “-regtest”:
`Bash
Go Go -Node = 127.0.0.0.1: 8545./src/contract/recipynt — Regtest
`
- Create a new deal that causes a contract and sends funds:
“ SOLIDITY
Pragma Solidity ^0.8.0;
Import ” SOL”;
Import “
The contract of the contract {
Use for SAVEERC20 for operating systems (ERC20.ierc20);
ERC20 public pay;
Constructor (_paelapable address) {
Patable = ERC20 (_ Mounted);
}
Receiving a Function () Public Salary Return (BOOL) {
return the truth;
}
}
Pragma Solidity ^0.8.0;
Import “https: // github.