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

All config files are located in config/. The main configuration is config/config.js:

const config = {
  senderPassphrase: '', // REPLACE senderPassphrase WITH THE PASSPHRASE OF YOUR WALLET
  senderSecondPassphrase: '', // REPLACE senderSecondPassphrase WITH THE SECOND PASSPHRASE OF YOUR WALLET if you have one
  peer: {
    apiTxPoolUrl: 'https://testnet.mainsailhq.com/tx',
    apiEvmUrl: 'https://testnet.mainsailhq.com/rpc',
  },
  gasPrice: '5000000000',
  transfer: {
    recipientAddress: '0xC870aF84F11e0d43c8a29C041F23a8E85a2Ce4ff',
    value: '350000000000000000000',
  },
  evmDeploy: {
    data: DARK20.bytecode,
    vendorField: '',
  },
  contracts: {
    consensus,
    usernames,
    multiPayment,
    dark20,
    revert,
    tokenTransfer,
  },
  message: {
    publicKey:
      '0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d',
    message: 'Hello, world!',
    signature:
      '0e2e53409be748834cac44052817ecef569b429a0492aa6bbc0d934eb71a09547e77aeef33d45669bbcba0498149f0e2b637fe8905186e08a5410c6f2b013bb41b',
  },
  crypto: crypto,
}

The default configuration is for the Public Testnet.

Adjust senderPassphrase and transaction data (recipientAddress, gasPrice, value, ...) before sending a TX. If you want to use an address with a second signature registered, make sure to set senderSecondPassphrase in addition!

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 - Deploy
3 - Consensus
4 - Usernames
5 - MultiPayment
6 - DARK20
7 - Revert
8 - Token Transfer

Send transfer

pnpm run start 1 <address (optional)> <amount (optional)>

Deploy contract

pnpm run start 2

Interact with contract

pnpm run start <contract_id> <function_id> <address (optional)> <amount (optional)>

<contract_id> refers to either of the below:

3 - Consensus
4 - Usernames
5 - MultiPayment
6 - DARK20
8 - Token Transfer

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',
  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 3 3

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.