On-chain registration

Abstract

Wirex Pay Chain leverages smart contracts to automate and secure interactions on its blockchain infrastructure. To interact with these smart contracts, developers need to use the Application Binary Interface (ABI), which defines the functions, events, and data structures within the contract. Using ABI calls, developers can interact with the contract directly to perform functions such as account creation, balance updates, asset transfers, and transaction confirmations on the Wirex Pay Chain.

Requirements

  • ABI File: The ABI file provides a list of callable functions and data types for the smart contract. You’ll need this file to understand how to structure API requests for interacting with the Wirex Pay Chain.
  • Web3 Library: A library like Web3.py is necessary to establish a connection with the Wirex Pay Chain and interact with the smart contract. Web3 allows developers to create instances of the smart contract and call functions directly.
  • Wirex Pay Chain Addresses: Separate addresses for Testnet and Mainnet provide the endpoints for testing and production environments.
  • Native token balance to cover the fee. For TestNet can be obtained from the faucet

ABI Account creation

 {
   "type": "function",
   "name": "createAccount",
   "constant": false,
   "payable": false,
   "inputs": [],
   "outputs": []
 }

Smart contract addresses

• Testnet Address: 0x3fe04562Fc28b4152F24A41E8A8c3899E6B8c433
• Mainnet Address: 0x2766F66E572C94a4cbc57f4d5bd2aD71900edF30

These addresses enable developers to deploy, test, and execute functions on Wirex Pay Chain’s non-custodial, zk-Rollup infrastructure. Be sure to use the appropriate address based on the environment you’re working in.

RPC URL and Chain Id can be found at Useful links.

Example: Account Creation via ABI Call

To create an account on the Wirex Pay Chain using ABI, follow these steps:

Package installation

pip install web3

Script example

from web3 import Web3

# Replace with your RPC server URL
rpc_url = "https://rpc-dev.wirexpaychain.com"

# Load your contract's ABI
contract_abi = [
    {
        "type": "function",
        "name": "createAccount",
        "constant": False,
        "payable": False,
        "inputs": [],
        "outputs": []
    }
    # Add the rest of the ABI if necessary
]

# Replace with your contract address, Account conract
contract_address = "0x062AfB76614dd594A99e70fD2CfbDf417CCF8797"

# Replace with your private key for signing the transaction
private_key = "{private_key}"

# Replace with your Ethereum wallet address
account_address = "{wallet_address}"

# Connect to the Ethereum network via the provided RPC URL
web3 = Web3(Web3.HTTPProvider(rpc_url))

if web3.is_connected():
    print("Connected to the Wirex Pay Testnet network")
else:
    print("Failed to connect")

# Create the contract instance
contract = web3.eth.contract(address=contract_address, abi=contract_abi)

# Get the nonce (transaction count) for the account
nonce = web3.eth.get_transaction_count(account_address)

# Get the current gas price from the network (or use a reasonable value)
# Option 1: Get gas price from network
gas_price = web3.eth.gas_price
# Option 2: Set a specific gas price (in wei)
# gas_price = web3.to_wei(1, 'gwei')  # 1 gwei

print(f"Using gas price: {web3.from_wei(gas_price, 'gwei')} gwei")

# Build the transaction to call the `createAccount` function
txn = contract.functions.createAccount().build_transaction({
    'chainId': 1001996,  # Use appropriate chain ID
    'gas': 200000,       # Estimate gas
    'gasPrice': gas_price,  # Use the gas price we determined
    'nonce': nonce
})

# Sign the transaction using the private key
signed_txn = web3.eth.account.sign_transaction(txn, private_key=private_key)

# Send the signed transaction
tx_hash = web3.eth.send_raw_transaction(signed_txn.raw_transaction)

# Print the transaction hash
print(f"Transaction hash: {tx_hash.hex()}")

# Wait for the transaction receipt (optional)
receipt = web3.eth.wait_for_transaction_receipt(tx_hash)
print(f"Transaction receipt: {receipt}")

Connected to the Wirex Pay Testnet network
Using gas price: 0.1 gwei
Transaction hash: 9bd8f676d4ea4815f2d989f22f876245b6eef68d97a10c74fd071eb9eb180543
Transaction receipt: AttributeDict({'blockHash': HexBytes('0x05617c99b5da3807dbf9e3c254314edf850e5ae2fc63176b42c3043fddb0298b'), 'blockNumber': 788691, 'contractAddress': None, 'cumulativeGasUsed': 49787, 'effectiveGasPrice': 100000000, 'from': '0x1101931EC1E18d642CE040f77a2d7c25c1b9FF66', 'gasUsed': 49787, 'logs': [AttributeDict({'address': '0x062AfB76614dd594A99e70fD2CfbDf417CCF8797', 'topics': [HexBytes('0x805996f252884581e2f74cf3d2b03564d5ec26ccc90850ae12653dc1b72d1fa2')], 'data': HexBytes('0x0000000000000000000000001101931ec1e18d642ce040f77a2d7c25c1b9ff66'), 'blockNumber': 788691, 'transactionHash': HexBytes('0x9bd8f676d4ea4815f2d989f22f876245b6eef68d97a10c74fd071eb9eb180543'), 'transactionIndex': 0, 'blockHash': HexBytes('0x05617c99b5da3807dbf9e3c254314edf850e5ae2fc63176b42c3043fddb0298b'), 'logIndex': 0, 'removed': False})], 'logsBloom': HexBytes('0x00000000000001000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000'), 'status': 1, 'to': '0x062AfB76614dd594A99e70fD2CfbDf417CCF8797', 'transactionHash': HexBytes('0x9bd8f676d4ea4815f2d989f22f876245b6eef68d97a10c74fd071eb9eb180543'), 'transactionIndex': 0, 'type': 0})

What’s Next