Class: CryptomateApi::Mpc::Wallet
- Defined in:
- lib/cryptomate_api/mpc/wallet.rb
Overview
The accounts module allows you to create and manage multiple accounts, each with their own wallets. This allows you to manage your crypto assets in a more organized manner, and also allows you to create multiple wallets for the same or different blockchain.
Class Method Summary collapse
-
.create_wallet(account_id, alias_name, blockchain) ⇒ Object
Create a new wallet for an account cryptomate.me/docs/mpc/create-a-wallet Response: { “id”: “string”, “alias”: “string”, “wallet_address”: “string”, “blockchain”: “string” }.
-
.get_all_wallets(account_id) ⇒ Object
Get all wallets for an account cryptomate.me/docs/mpc/get-all-wallets TODO: check response if it’s an array or a hash Response: { “id”: “string”, “alias”: “string”, “wallet_address”: “string”, “blockchain”: “string” }.
-
.get_balance(account_id, wallet_id) ⇒ Object
Get balance cryptomate.me/docs/mpc#balance Returns the balance of all the listed tokens from the blockchain of a wallet, with the amount of them even if they are 0.
-
.get_wallet(account_id, wallet_id) ⇒ Object
Get a wallet: Retrieves a wallet by ID.
-
.transfer_token(account_id, wallet_id, token_address, amount, to) ⇒ Object
Transfer Token Transfer any of the listed tokens that are in your MPC wallet to another wallet (internal or external).
-
.update_wallet(account_id, wallet_id, alias_name) ⇒ Object
Update a wallet: Modifies the wallet information.
Class Method Details
.create_wallet(account_id, alias_name, blockchain) ⇒ Object
Create a new wallet for an account cryptomate.me/docs/mpc/create-a-wallet Response:
"id": "string",
"alias": "string",
"wallet_address": "string",
"blockchain": "string"
52 53 54 |
# File 'lib/cryptomate_api/mpc/wallet.rb', line 52 def create_wallet(account_id, alias_name, blockchain) post("/mpc/accounts/#{account_id}/wallets/create", body: { alias: alias_name, blockchain: }.to_json) end |
.get_all_wallets(account_id) ⇒ Object
Get all wallets for an account cryptomate.me/docs/mpc/get-all-wallets TODO: check response if it’s an array or a hash Response:
"id": "string",
"alias": "string",
"wallet_address": "string",
"blockchain": "string"
36 37 38 |
# File 'lib/cryptomate_api/mpc/wallet.rb', line 36 def get_all_wallets(account_id) get("/mpc/accounts/#{account_id}/wallets/list") end |
.get_balance(account_id, wallet_id) ⇒ Object
Get balance cryptomate.me/docs/mpc#balance Returns the balance of all the listed tokens from the blockchain of a wallet, with the amount of them even if they are 0. Response: [
{
"name": "string",
"symbol": "string",
"balance": 0.0,
"token_address": "string"
}
]
113 114 115 |
# File 'lib/cryptomate_api/mpc/wallet.rb', line 113 def get_balance(account_id, wallet_id) get("/mpc/accounts/#{account_id}/wallets/#{wallet_id}/balance") end |
.get_wallet(account_id, wallet_id) ⇒ Object
Get a wallet: Retrieves a wallet by ID. cryptomate.me/docs/mpc/get-a-wallet Response:
"id": "string",
"alias": "string",
"wallet_address": "string",
"blockchain": "string"
21 22 23 |
# File 'lib/cryptomate_api/mpc/wallet.rb', line 21 def get_wallet(account_id, wallet_id) get("/mpc/accounts/#{account_id}/wallets/#{wallet_id}") end |
.transfer_token(account_id, wallet_id, token_address, amount, to) ⇒ Object
Transfer Token Transfer any of the listed tokens that are in your MPC wallet to another wallet (internal or external). The status determines the transaction state. Normally, the service will return SUCCESSFUL or FAILED. In some cases, if the blockchain is congested, the service may return a PENDING state, which means that the transaction is still waiting to be processed. But sometimes, due to variations in gas prices from block to block, a transaction may be in a state where it was sent to be processed but the blockchain did not program it to be executed. In these cases, the transaction will be marked as MANUAL_CHECK and will need to be verified manually. cryptomate.me/docs/mpc/transfer-token Response:
"transaction_hash": "string",
"status": "success|failed|pending|manual_check"
91 92 93 94 95 96 |
# File 'lib/cryptomate_api/mpc/wallet.rb', line 91 def transfer_token(account_id, wallet_id, token_address, amount, to) post( "/mpc/accounts/#{account_id}/wallets/#{wallet_id}/transfer", body: { token_address:, amount:, to: }.to_json ) end |
.update_wallet(account_id, wallet_id, alias_name) ⇒ Object
Update a wallet: Modifies the wallet information. cryptomate.me/docs/mpc/update-wallet Response:
"id": "string",
"alias": "string",
"wallet_address": "string",
"blockchain": "string"
68 69 70 |
# File 'lib/cryptomate_api/mpc/wallet.rb', line 68 def update_wallet(account_id, wallet_id, alias_name) put("/mpc/accounts/#{account_id}/wallets/#{wallet_id}", body: { alias: alias_name }.to_json) end |