Ethereum: Receipt of Money Regression Test (Regtest) mode
When developing your application that interacts with the Bitcoin server to find details of events with an event ID, it is necessary to consider using Ethereum for additional functions. One such way of use is receiving money through the Regtest mode, which allows you to test and validate your app without revealing your Mounts wallet. Here is an article on how to receive funds in Regtest mode in Ethereum.
What is the regression test mode?
The regression test mode simulates the event with the same event code as the one used to create it in Mainet, but without sending or receiving funds. This will help you check that your code behaves correctly and do not present errors that may appear after deployment.
Setting Ethereum in Regtest mode
Before continuing, make sure you have a node.JS, a geth (Go Ethereum customer) and a truffle package installed on your machine.
conditions
- Install the required packages:
– npm install @truffel/core
orthread add truffle cores
– NPM Install @TRYFFEL/Compile
orthread Add Compile
- Create a new projectNPX TRYFFEL INIT
- Set up the Mainnet and Regtest networks in the.env
file.
To determine the
Ethereum network
You need to update your web configuration underConfig/Congums.json. Make sure you have the next installation:
Json
{
“Network”: {
“Mountains”: True,
“Regtest”: Wrong,
“Rpc”: “
“Eth1”: {
“Rpc”: “
},
}
}
`
Replace Your_project_id
with your real infrastructure project ID.
Creating a contract for receiving funds
Create a new file called src/conguming/recipient.sol
. Here is an example agreement:
`Solidity
Pragman solidity ^0.8.0;
Import “
Import “
The recipient of the contract {
using the Safeerc20 (ERC20.IERC20);
ERC20 public payable;
Builder (address _payble) {
Payable = ERC20 (_Payable);
}
Action to receive () Public Payable Refunds (Bool) {
return the truth;
}
}
`
Testing a contract with regest
To test your contract without submitting or receiving funds, you can use a combination of commands:
- Start your geth node:
`Bash
Go Run -Node = 127.0.0.1: 8545 ./SRC/Contract/recipient -regtest
`
- Turn and take an intelligent contract to the Ethereum network.
- Use Tryffl’s
Compile
command to turn and update the contract in your local Regtest environment.
For example:
`Bash
NPX trryffel environment
truffle move -network- = regtest
`
receiving funds in Regtest mode
Once you have successfully introduced and updated your intelligent contract, you can test your funds in Regtest mode. Thus:
- Start your geth node
-Regtest
ticket:
`Bash
Go Run -Node = 127.0.0.1: 8545 ./SRC/Contract/recipient -regtest
`
- Create a new event that invites the agreement and sends funds:
`Solidity
Pragman solidity ^0.8.0;
Import “
Import “
The recipient of the contract {
using the Safeerc20 (ERC20.IERC20);
ERC20 public payable;
Builder (address _payble) {
Payable = ERC20 (_Payable);
}
Action to receive () Public Payable Refunds (Bool) {
return the truth;
}
}
Pragman solidity ^0.8.0;
Bring “https: // github.