Module: wallet
Class for interacting with an Infernet Wallet contract.
Attributes
address: The address of the wallet contract
Public Methods
approve(spender: ChecksumAddress, token: ChecksumAddress, amount: int) -> TxReceipt: Approve a spender to spend a certain amount of tokensowner() -> ChecksumAddress: Get the owner of the walletget_balance() -> int: Get the native balance of the walletget_token_balance(token: ChecksumAddress) -> int: Get the balance of a token in the walletwithdraw(token: ChecksumAddress, amount: int) -> TxReceipt: Withdraw an amount of unlocked tokens (only by wallet owner)
InfernetWallet
Source code in src/infernet_client/chain/wallet.py
__init__(address, rpc)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address |
ChecksumAddress
|
The address of the wallet contract |
required |
rpc |
RPC
|
The RPC object to interact with the blockchain |
required |
Source code in src/infernet_client/chain/wallet.py
approve(spender, token, amount)
async
Approve a spender to spend a certain amount of tokens
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spender |
ChecksumAddress
|
The address of the spender |
required |
token |
ChecksumAddress
|
The address of the token to approve |
required |
amount |
int
|
The amount to approve |
required |
Returns:
| Type | Description |
|---|---|
TxReceipt
|
The transaction receipt |
Source code in src/infernet_client/chain/wallet.py
get_balance()
async
Get the native balance of the wallet
Returns:
| Type | Description |
|---|---|
int
|
The native balance |
get_token_balance(token)
async
Get the balance of a token in the wallet
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token |
ChecksumAddress
|
The address of the token |
required |
Returns:
| Type | Description |
|---|---|
int
|
The balance of the token |
Source code in src/infernet_client/chain/wallet.py
owner()
async
Get the owner of the wallet
Returns:
| Type | Description |
|---|---|
ChecksumAddress
|
The address of the owner |
withdraw(token, amount)
async
Withdraw tokens not locked in escrow. Only usable by wallet owner
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token |
ChecksumAddress
|
The address of the token |
required |
amount |
int
|
The amount to withdraw |
required |
Returns:
| Type | Description |
|---|---|
TxReceipt
|
The transaction receipt |