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.

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

# RPC server URL
rpc_url = "https://wirex-devnet-rpc.eu-north-2.gateway.fm/"

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

# Contract address
contract_address = "0x3fe04562Fc28b4152F24A41E8A8c3899E6B8c433"

# Private key for signing the transaction
private_key = "{privateKey}"

# Ethereum wallet address
account_address = "{walletAddress}"

# Connect to the Wirex Pay Testnet 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)

# Build the transaction to call the `createAccount` function
txn = contract.functions.createAccount().build_transaction({
    'chainId': 230378335,  # Use appropriate chain ID, 1 for mainnet
    'gas': 200000,  # Estimate gas
    'gasPrice': 0,  # Set appropriate gas price
    '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
Transaction hash: b61532ff5b67e9ebf68eeb9b6a0544a921e876977863971088098e77b870378c
Transaction receipt: AttributeDict({'cumulativeGasUsed': 51268, 'logsBloom': HexBytes('0x00000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000004000000000000000000000000000000000000000000000000000000000100000000000000000000000'), 'logs': [AttributeDict({'address': '0x3fe04562Fc28b4152F24A41E8A8c3899E6B8c433', 'topics': [HexBytes('0x805996f252884581e2f74cf3d2b03564d5ec26ccc90850ae12653dc1b72d1fa2')], 'data': HexBytes('0x000000000000000000000000848efac21cdba93b481f1a40b54af00a8db994c0'), 'blockNumber': 3273669, 'transactionHash': HexBytes('0xb61532ff5b67e9ebf68eeb9b6a0544a921e876977863971088098e77b870378c'), 'transactionIndex': 0, 'blockHash': HexBytes('0xb56b75d7340531b07dddeef3424a77dff3300e04d2c2f6cb20e70eb0619cdca0'), 'logIndex': 0, 'removed': False})], 'status': 1, 'transactionHash': HexBytes('0xb61532ff5b67e9ebf68eeb9b6a0544a921e876977863971088098e77b870378c'), 'transactionIndex': 0, 'blockHash': HexBytes('0xb56b75d7340531b07dddeef3424a77dff3300e04d2c2f6cb20e70eb0619cdca0'), 'blockNumber': 3273669, 'gasUsed': 51268, 'from': '0x848efaC21cdBA93b481F1a40b54Af00A8Db994c0', 'to': '0x3fe04562Fc28b4152F24A41E8A8c3899E6B8c433', 'contractAddress': None, 'type': 0, 'effectiveGasPrice': 0})

Process finished with exit code 0

What’s Next