Developers Documentation
Docs Menu
1. PAXI CLI Commands
1.1 Install PAXI CLI
curl -sL https://raw.githubusercontent.com/paxi-web3/paxi/main/scripts/cli_install.sh | bash
1.2 Add Key
# Add a new key
paxid keys add your_key_name
# Import key from seed phrase
paxid keys add your_key_name --recover
1.3 Send PAXI
paxid tx bank send your_key_name paxi1... 1000000upaxi \
--gas auto --fees 30000upaxi
1.4 Query Balances
paxid q bank balances paxi1...
1.5 Upload Contract
paxid tx wasm store your_contract.wasm \
--from your_key_name --gas auto --fees 10000000upaxi
1.6 Create PRC-20 Token
paxid tx wasm instantiate 1 '{
"name": "TestToken",
"symbol": "TST",
"decimals": 6,
"initial_balances": [
{
"address": "paxi1...",
"amount": "1000000"
}
],
"mint": {
"minter": "paxi1..."
},
"marketing": {
"project": "TestToken Project",
"description": "This is a test token",
"marketing": "paxi1...",
"logo": {
"url": "ipfs://bafkreiaaaaabbbbccccddddeeeeffff11112222333344445555666677778888"
}
}
}' --from your_key_name --label "TestToken" --no-admin --gas auto --fees 6000000upaxi
# Wait for 5 seconds and run the command below to get the contract address
curl -s 'GET' 'http://127.0.0.1:1317/cosmos/tx/v1beta1/txs/44E8739BF4F7C7B3148CC9BF9E2F3961FAA06ADEEEFC7F421190746DA3DE8104' | jq -r '.tx_response.events[]
| select(.type=="instantiate")
| .attributes[]
| select(.key=="_contract_address")
| .value'
1.7 Create PRC-721 NFT
paxid tx wasm instantiate 2 \
'{"name":"Test NFT","symbol":"TNFT","minter":"paxi1..."}' \
--from your_key_name \
--label "Test Collections" \
--no-admin \
--gas auto \
--fees 6000000upaxi
# Wait for 5 seconds and run the command below to get the contract address
curl -s 'GET' 'http://127.0.0.1:1317/cosmos/tx/v1beta1/txs/44E8739BF4F7C7B3148CC9BF9E2F3961FAA06ADEEEFC7F421190746DA3DE8104' | jq -r '.tx_response.events[]
| select(.type=="instantiate")
| .attributes[]
| select(.key=="_contract_address")
| .value'
paxid tx wasm execute prc721_contract_addr \
'{"mint": {"token_id": "test_001", "owner": "paxi1...", "token_uri": "https://example.com/test_meta.json"}}' \
--from your_key_name \
--gas auto \
--fees 20000upaxi
1.8 Transfer PRC-20 NFT
paxid tx wasm execute prc20_contract_addr '{"transfer":{"recipient":"paxi1...","amount":"1000"}}' \
--from your_key_name --gas auto --fees 30000upaxi
1.9 Transfer PRC-721 NFT
paxid tx wasm execute prc721_contract_addr '{"transfer_nft":{"recipient":"paxi1...","token_id":"1","minter":"paxi1..."}}' \
--from your_key_name --gas auto --fees 30000upaxi
1.10 Query PRC-20 Balance
paxid query wasm contract-state smart prc20_contract_addr '{"balance":{"address":"paxi1..."}}'
1.11 Query PRC-721 Details
paxid query wasm contract-state smart prc721_contract_addr '{"nft_info":{"token_id":"1"}}'
1.12 More Details (--help)
paxid --help
paxid tx --help
paxid query wasm --help
1.13 Increase Allowance
./paxid tx wasm execute your_contract_address \
'{"increase_allowance": {
"spender": "paxi1mfru9azs5nua2wxcd4sq64g5nt7nn4n80r745t", # This is the swap module's address
"amount": "10000000000000"
}}' \
--from your_key_name \
--gas auto \
--fees 21000upaxi
1.14 Provide Liquidity
# Remember to increase allowance to the swap module before executing this command
./paxid tx swap provide-liquidity \
--prc20 "your_contract_address" \
--paxi-amount "1000000upaxi" \
--prc20-amount "10000000" \
--from your_key_name \
--gas auto \
--fees 21000upaxi
1.15 Withdraw Liquidity
./paxid tx swap withdraw-liquidity \
--prc20 "your_contract_address" \
--lp-amount "1000000" \
--from your_key_name \
--gas auto \
--fees 21000upaxi
1.16 Swap
# Remember to increase allowance to the swap module before executing this command
./paxid tx swap swap \
--prc20 "your_contract_address" \
--offer-denom upaxi \
--offer-amount 10000 \
--min-receive 10 \
--from your_key_name \
--gas auto \
--fees 21000upaxi
2. REST API
2.1 GET Transaction by Hash
GET https://mainnet-lcd.paxinet.io/cosmos/tx/v1beta1/txs/{hash}
2.2 GET Transactions in Block
GET https://mainnet-lcd.paxinet.io/cosmos/tx/v1beta1/txs/block/{block_height}
2.3 GET Node Status
GET https://mainnet-lcd.paxinet.io/cosmos/base/node/v1beta1/status
2.4 GET Latest Block
GET https://mainnet-lcd.paxinet.io/cosmos/base/tendermint/v1beta1/blocks/latest
2.5 GET Validators
GET https://mainnet-lcd.paxinet.io/cosmos/staking/v1beta1/validators
2.6 GET Balances
GET https://mainnet-lcd.paxinet.io/cosmos/bank/v1beta1/balances/{address}
2.7 GET Account Info
GET https://mainnet-lcd.paxinet.io/cosmos/auth/v1beta1/accounts/{address}
2.8 GET Circulating Supply
GET https://mainnet-lcd.paxinet.io/paxi/paxi/circulating_supply
2.9 GET Locked Vesting
GET https://mainnet-lcd.paxinet.io/paxi/paxi/locked_vesting
2.10 GET Total Supply
GET https://mainnet-lcd.paxinet.io/paxi/paxi/total_supply
2.11 GET Unlock Schedules
GET https://mainnet-lcd.paxinet.io/paxi/paxi/unlock_schedules
2.12 GET All Swap Pools
GET https://mainnet-lcd.paxinet.io/paxi/swap/all_pools
2.13 GET Swap Pool Details
GET https://mainnet-lcd.paxinet.io/paxi/swap/pool/{prc20_address}
2.14 Swagger UI
Using Swagger UI, you can explore detailed documentation for all API endpoints, view parameter schemas, example requests/responses, and test the APIs directly in your browser.
Open Swagger UI3. JavaScript SDK
3.1 Import & Setup
// Proto source code for TypeScript: https://github.com/paxi-web3/paxi/tree/main/ts_proto
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { SigningStargateClient, coins, calculateFee, GasPrice } from "@cosmjs/stargate";
// endpoints & config
const rpcEndpoint = "https://mainnet-rpc.paxinet.io";
const lcdEndpoint = "https://mainnet-lcd.paxinet.io";
const prefix = "paxi";
const denom = "upaxi";
3.2 Initialize Wallet
async function initWallet(mnemonic) {
// create wallet from mnemonic
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix });
const [firstAccount] = await wallet.getAccounts();
return { wallet, address: firstAccount.address };
}
// Usage:
// const mnemonic = "your twelve word mnemonic here";
// const { wallet, address } = await initWallet(mnemonic);
3.3 Get Chain ID
async function fetchChainId() {
const client = await SigningStargateClient.connect(rpcEndpoint);
const chainId = await client.getChainId();
return chainId;
}
// Usage:
// const chainId = await fetchChainId();
3.4 Get Account Info
async function fetchAccountInfo(address) {
const client = await SigningStargateClient.connect(rpcEndpoint);
const account = await client.getAccount(address);
return {
accountNumber: account.accountNumber,
sequence: account.sequence
};
}
// Usage:
// const info = await fetchAccountInfo("paxi1...");
3.5 Build & Send Transaction
async function sendTokens(mnemonic, toAddress, amount, memo = "") {
const { wallet, address } = await initWallet(mnemonic);
const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet);
const fee = calculateFee(200_000, GasPrice.fromString('0.0upaxi')); // gas & fee
const result = await client.sendTokens(
address,
toAddress,
coins(amount, denom),
fee,
memo,
);
return result.transactionHash;
}
// Usage:
// const txHash = await sendTokens("your mnemonic", "paxi1dest...", "1000000", "Test transfer");
4. Python SDK
4.1 Import & Setup
# cosmpy==0.11.1
# mospy-wallet==0.6.0
from mospy import Account, Transaction
import requests
import json
from datetime import datetime, timedelta
from cosmpy.crypto.address import Address
paxi_lcd = 'https://mainnet-lcd.paxinet.io'
paxi_rpc = 'https://mainnet-rpc.paxinet.io'
4.2 Fetch Chain ID
def fetch_chain_id(lcd_url: str) -> str:
resp = requests.get(f"{lcd_url}/cosmos/base/tendermint/v1beta1/node_info")
resp.raise_for_status()
return resp.json()["default_node_info"]["network"]
# Usage
chain_id = fetch_chain_id(paxi_lcd)
4.3 Fetch Account Info
def fetch_account_info(lcd_url: str, address: str) -> tuple[int, int]:
url = f"{lcd_url}/cosmos/auth/v1beta1/accounts/{address}"
r = requests.get(url)
data = r.json()
base_account = data.get("account", {})
return int(base_account.get("account_number", 0)), int(base_account.get("sequence", 0))
# Usage
acct_num, seq = fetch_account_info(paxi_lcd, "paxi1...")
4.4 Send Transaction
def send_tx(account: Account, to_address: str, amount: float,
fee: float, chain_id: str, lcd_url: str, memo: str = "") -> str | None:
tx = Transaction(
account=account,
gas=int(fee * 10**6 / 0.05),
chain_id=chain_id,
memo=memo
)
tx.set_fee(amount=int(fee * 10**6), denom=denom)
tx.add_msg(
tx_type="transfer",
sender=account,
recipient=to_address,
amount=int(amount * 10**6),
denom=denom
)
payload = {
"tx_bytes": tx.get_tx_bytes_as_string(),
"mode": "BROADCAST_MODE_ASYNC"
}
resp = requests.post(f"{lcd_url}/cosmos/tx/v1beta1/txs", json=payload)
resp.raise_for_status()
return resp.json().get("tx_response", {}).get("txhash")
4.5 Check Transaction Status
def fetch_tx_status(lcd_url: str, tx_hash: str) -> dict:
url = f"{lcd_url}/cosmos/tx/v1beta1/txs/{tx_hash}"
resp = requests.get(url)
if resp.status_code != 200:
return {"status": "pending", "detail": "Node unreachable"}
data = resp.json().get("tx_response", {})
code = data.get("code", 0)
if code == 0:
return {"status": "success", "height": data.get("height")}
return {"status": "failed", "code": code, "raw_log": data.get("raw_log")}
# Usage
status = fetch_tx_status(paxi_lcd, "HASH123...")
4.6 Validate Address
def is_valid_bech32_address(addr: str, hrp: str = "paxi") -> bool:
try:
assert addr.startswith(hrp)
Address(addr) # raises if invalid
return True
except Exception:
return False
# Usage
valid = is_valid_bech32_address("paxi1...") # True or False
4.7 Send Transaction Example
# 1. Import account from mnemonic
mnemonic = "canal lazy unveil sort dwarf bacon measure spawn increase neutral winter lucky"
account = Account(seed_phrase=mnemonic, hrp='paxi')
account_number, sequence = fetch_account_info(paxi_lcd, account.address)
account.account_number = account_number
account.next_sequence = sequence
# Alternative: import account from hex-encoded private key
# priv_key_hex = "abcdef1234567890..."
# account = Account(private_key=priv_key_hex, hrp='paxi')
# 2. Define transaction parameters
to_address = "paxi1..."
amount = 1.5 # amount in PAXI
fee = 0.04 # fee in PAXI
chain_id = fetch_chain_id(paxi_lcd)
memo = "Test transfer via Python SDK"
# 3. Send transaction and retrieve transaction hash
tx_hash = send_tx(account, to_address, amount, fee, chain_id, paxi_lcd, memo)
print(f"Transaction hash: {tx_hash}")