Remote Procedure Call (RPC)¶
Bytom remote procedure call.
-
swap.providers.bytom.rpc.
get_balance
(address: str, asset: str = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', network: str = 'mainnet', headers: dict = {}, timeout: int = 60) → int¶ Get Bytom balance.
- Parameters
address (str) – Bytom address.
asset (str) – Bytom asset, default to BTM asset.
network (str) – Bytom network, defaults to mainnet.
headers (dict) – Request headers, default to common headers.
timeout (int) – Request timeout, default to 15.
- Returns
int – Bytom asset balance (NEU amount).
>>> from swap.providers.bytom.rpc import get_balance >>> get_balance(address="bm1q9ndylx02syfwd7npehfxz4lddhzqsve2fu6vc7", asset="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", network="mainnet") 2580000000
-
swap.providers.bytom.rpc.
build_transaction
(address: str, transaction: dict, network: str = 'mainnet', headers: dict = {}, timeout: int = 60) → dict¶ Build Bytom transaction.
- Parameters
address (str) – Bytom address.
transaction (dict) – Bytom transaction.
network (str) – Bytom network, defaults to mainnet.
headers (dict) – Request headers, default to common headers.
timeout (int) – Request timeout, default to 60.
- Returns
dict – Bytom built transaction.
>>> from swap.providers.bytom.rpc import build_transaction >>> build_transaction(address="bm1q9ndylx02syfwd7npehfxz4lddhzqsve2fu6vc7", transaction={...}, network="mainnet") {...}
-
swap.providers.bytom.rpc.
get_utxos
(program: str, network: str = 'mainnet', asset: str = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', limit: int = 15, by: str = 'amount', order: str = 'desc', headers: dict = {}, timeout: int = 60) → list¶ Get Bytom unspent transaction outputs (UTXO’s).
- Parameters
program (str) – Bytom control program.
network (str) – Bytom network, defaults to mainnet.
asset (str) – Bytom asset id, defaults to BTM asset.
limit (int) – Bytom utxo’s limit, defaults to 15.
by (str) – Sort by, defaults to amount.
order (str) – Sort order, defaults to desc.
headers (dict) – Request headers, default to common headers.
timeout (int) – Request timeout, default to 60.
- Returns
list – Bytom unspent transaction outputs (UTXO’s).
>>> from swap.providers.bytom.rpc import get_utxos >>> get_utxos(program="00142cda4f99ea8112e6fa61cdd26157ed6dc408332a", network="mainnet") [...]
-
swap.providers.bytom.rpc.
get_transaction
(transaction_id: str, network: str = 'mainnet', headers: dict = {}, timeout: int = 60) → dict¶ Get Bytom transaction detail.
- Parameters
transaction_id (str) – Bytom transaction id.
network (str) – Bytom network, defaults to mainnet.
headers (dict) – Request headers, default to common headers.
timeout (int) – Request timeout, default to 60.
- Returns
dict – Bytom transaction detail.
>>> from swap.providers.bytom.rpc import get_transaction >>> get_transaction(transaction_id="4e91bca76db112d3a356c17366df93e364a4922993414225f65390220730d0c1", network="mainnet") {...}
-
swap.providers.bytom.rpc.
decode_raw
(raw: str, network: str = 'mainnet', headers: dict = {}, timeout: int = 60) → dict¶ Decode original Bytom raw.
- Parameters
raw (str) – Bytom transaction raw.
network (str) – Bytom network, defaults to mainnet.
headers (dict) – Request headers, default to common headers.
timeout (int) – Request timeout, default to 60.
- Returns
dict – Bytom decoded transaction raw.
>>> from swap.providers.bytom.rpc import decode_raw >>> decode_raw(raw="...", network="testnet") {...}
-
swap.providers.bytom.rpc.
submit_raw
(address: str, raw: str, signatures: list, network: str = 'mainnet', headers: dict = {}, timeout: int = 60) → str¶ Submit original Bytom raw into blockchain.
- Parameters
address (str) – Bytom address.
raw (str) – Bytom transaction raw.
signatures (list) – Bytom signed massage datas.
network (str) – Bytom network, defaults to mainnet.
headers (dict) – Request headers, default to common headers.
timeout (int) – Request timeout, default to 60.
- Returns
str – Bytom submitted transaction id/hash.
>>> from swap.providers.bytom.rpc import submit_raw >>> submit_raw(address="...", raw="...", signatures=[[...], ...], network="...") "2993414225f65390220730d0c1a356c14e91bca76db112d37366df93e364a492"