Class: CryptomateApi::Mpc::Wallet

Inherits:
Base
  • Object
show all
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

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"

Parameters:

  • account_id (String)

    (Id of the account to create the wallet on.)

  • alias_name (String)

    (Alias name of the wallet to create.)

  • blockchain (String)

    (Blockchain of the wallet to create.)



52
53
54
# File 'lib/cryptomate_api/mpc/wallet.rb', line 52

def create_wallet(, alias_name, blockchain)
  post("/mpc/accounts/#{}/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"

Parameters:

  • account_id (String)

    (Id of the account to get the wallets from.)



36
37
38
# File 'lib/cryptomate_api/mpc/wallet.rb', line 36

def get_all_wallets()
  get("/mpc/accounts/#{}/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"
}

]

Parameters:

  • account_id (String)

    (Id of the account to get the balance from.)

  • wallet_id (String)

    (Id of the wallet to get the balance from.)



113
114
115
# File 'lib/cryptomate_api/mpc/wallet.rb', line 113

def get_balance(, wallet_id)
  get("/mpc/accounts/#{}/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"

Parameters:

  • account_id (String)

    (Id of the account to get the wallet from.)

  • wallet_id (String)

    (Id of the wallet to get.)



21
22
23
# File 'lib/cryptomate_api/mpc/wallet.rb', line 21

def get_wallet(, wallet_id)
  get("/mpc/accounts/#{}/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"

Parameters:

  • account_id (String)

    (Id of the account to transfer the token from.)

  • wallet_id (String)

    (Id of the wallet to transfer the token from.)

  • token_address (String)

    (Address of the contract for the token to transfer. This address can be obtained from the listed token API.)

  • amount (String)

    (Amount of the selected asset to be send. Ex: 123.45.)

  • to (String)

    (Address of the receiver wallet.)



91
92
93
94
95
96
# File 'lib/cryptomate_api/mpc/wallet.rb', line 91

def transfer_token(, wallet_id, token_address, amount, to)
  post(
    "/mpc/accounts/#{}/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"

Parameters:

  • account_id (String)

    (Id of the account to update the wallet on.)

  • wallet_id (String)

    (Id of the wallet to update.)

  • alias_name (String)

    (Alias to identify the wallet to update.)



68
69
70
# File 'lib/cryptomate_api/mpc/wallet.rb', line 68

def update_wallet(, wallet_id, alias_name)
  put("/mpc/accounts/#{}/wallets/#{wallet_id}", body: { alias: alias_name }.to_json)
end