Transaction Tester
The Mainsail TX Tester is a useful tool that allows you to create wallets and send transactions on the Mainsail Networks via command line. It can be found here.
Requirements
Ensure that you have a working Python binary in your PATH as this script compiles native crypto bindings (specifically https://github.com/ChainSafe/blst-ts will cause you issues). If you notice that you run into an error while installing the dependencies and one of the lines in the stack trace includes /bin/sh: python: command not found, this is your issue. A known scenario where this happens is on later macOS versions where only a python3 binary is present.
To resolve it, make sure Python is available on your system. One way to easily manage this is by using a Python version manager such as pyenv.
You can setup required software by following Step 3 - Step 6 outlined in the Installing from Source section.
Installation
Clone the Mainsail TX Tester repository:
git clone https://github.com/ArkEcosystem/mainsail-tx-tester.git
cd mainsail-tx-tester
pnpm i
pnpm run build
Configuration
Configuration files exist in the config folder. Inside there you'll find networks/**/ for network related details, and contracts/**/ for contract related details. The main configuration files are config/config.js for configuring transfers, and config/networks/testnet.js to setup your testnet configuration.
export const testnet = {
privateKey: '',
senderPassphrase: '', // REPLACE senderPassphrase WITH THE PASSPHRASE OF YOUR WALLET
senderSecondPassphrase: '', // REPLACE senderSecondPassphrase WITH THE SECOND PASSPHRASE OF YOUR WALLET if you have one
peer: 'https://testnet.mainsailhq.com/rpc/api',
waitForBlock: true,
crypto: crypto,
}
The default configuration is for the Public Testnet. Adjust the senderPassphrase and senderSecondPassphrase fields with the passphrase(s) of your wallet. The peer field can be adjusted to point to a different node if needed.
When sending transfers, the transaction data (recipient address, amount, gas price, etc.) are configured in config/config.js.
When interacting with contracts, the function calls are parameterized based on the configurations under config/contracts/.
Usage
Show help
pnpm run start
Please provide TX number in arguments:
1 - Transfer
2 - Consensus
3 - Usernames
4 - MainsailERC20
5 - MultiPayment
6 - DARK20
7 - Revert
8 - Test
9 - ERC20BatchTransfer
Send transfer
pnpm run start 1 <address (optional)> <amount (optional)>
Interact with contract
pnpm run start <contract_id> <function_id> <address (optional)> <amount (optional)>
<contract_id> refers to either of the below:
2 - Consensus
3 - Usernames
4 - MainsailERC20
5 - MultiPayment
6 - DARK20
7 - Revert
8 - Test
9 - ERC20BatchTransfer
The corresponding configurations are inside config/contracts/ named after the respective contract.
<function_id> is based on the invoked contract. For example, take a look at config/contracts/consensus.js:
export const consensus = {
abi: ConsensusAbi.abi,
name: 'Consensus',
bytecode: ConsensusAbi.bytecode.object,
contractId: '0x535B3D7A252fa034Ed71F0C53ec0C6F784cB64E1',
transactions: [
{
functionName: 'registerValidator',
amount: '250000000000000000000',
args: [`0x${'0'.repeat(96)}`],
},
{
functionName: 'updateValidator',
args: [`0x${'1'.repeat(96)}`],
},
{
functionName: 'resignValidator',
args: [],
},
{
functionName: 'vote',
args: ['0x8233F6Df6449D7655f4643D2E752DC8D2283fAd5'],
},
{
functionName: 'unvote',
args: [],
},
],
}
<function_id> refers to the index of the transactions array.
To send a vote transaction with the script, you'd invoke it like this:
pnpm run start 2 4
In order to deploy any contract, you use the deploy function which is always the first item in the transactions array. So to deploy the Consensus contract, you'd invoke:
pnpm run start 2 0
Adjust the arguments inside the config files as needed.
Create Wallet
Generate wallet Mnemonic, Address and Public Key:
pnpm run wallet
Or with provided mnemonic:
pnpm run wallet "lottery end olympic solid end wonder index raw income switch twice marriage page tree replace cube daring engage ivory spy satisfy length cricket between"
Mnemonic: lottery end olympic solid end wonder index raw income switch twice marriage page tree replace cube daring engage ivory spy satisfy length cricket between
Validator Public Key: 99f717d581e058b526fce70db1e2838c19ca5f32b09222749e8ec6a9471d4a2dc0faee9ac47b7a02220ebc858a7fe049
Validator Private Key: 413af7c36350b573dc6c7ccd2f9b3370d47f4b23e7db435e0af5a01ecd723c84
Public Key: 03c5369d4c62dd62822bfeb25dc9343ea0a5b508dfe9b6402932b9c831216c04f9
Private Key: 2be1626052967ca7672557a4675afdacd3e6d719ebaacb80934f4c047a8b9d32
Address: 0xc6B9082374cb5a3f5b2B975B9B45894D0513c992
Receive tokens
Go to the Mainsail Faucet and enter the address generated in the previous step to receive some DARK tokens.
Troubleshooting
Ran into an issue? Check here first.
I can't install mainsail-tx-tester
There can be a few issues that cause the mainsail-tx-tester fail to install. Make sure you have the following packages and tools installed on your machine:
node- version 22+python- version 3.10+
If you notice it installs packages but fails due to something related to @chainsafe/blst, make sure to install python's setuptools when you are using python 3.12+. Refer to this stackoverflow answer on how to install it.