/get_wallet
Gets details about the user wallet used to generate the usersignature header.
This endpoint returns details about a wallet registered to a user, including:
- Wallet ID
- nickname
- whether it is a default destination
- whether it is whitelisted
- current balance
- current pending balance
When using legacy ECDSA authentication
The wallet/address to be examined is the one derived from the usersignature
header.
When using Authentication Tokens
The wallet/address to be examined is specified by either the nickname
or wallet_id
Requests
When using legacy ECDSA authentication
Both authsignature
and usersignature
are required for this request. The usersignature header should be generated with a keypair associated with the user; see Authentication section for more details.
When using Authentication Tokens
Use a valid access token in an Authorization: Bearer request header.
Note - We recently renamed the field auth_handle
to app_handle
. For backward compatibility, auth_handle
is still valid but has been removed from our documentation.
POST /0.2/get_wallet HTTP/1.1
sandbox.silamoney.com
Content-Type: application/json
// if using OAuth2
Authorization: Bearer [GENERATED JWT TOKEN HERE]
// if using ECDSA
authsignature: [GENERATED AUTHSIGNATURE HEX STRING HERE]
usersignature: [GENERATED USERSIGNATURE HEX STRING HERE]
// ECDSA
{
"header": {
"created": 1234567890,
"app_handle": "handle.silamoney.eth",
"user_handle":"user.silamoney.eth",
"version": "0.2",
"reference": "<your unique id>"
}
}
// Authentication Token
{
"header": {
"created": 1234567890,
"app_handle": "handle.silamoney.eth",
"user_handle":"user.silamoney.eth",
"version": "0.2",
"reference": "<your unique id>"
},
"nickname": "<wallet nickname>",
"wallet_id": "<wallet id>"
}
***
HTTP/1.1 200 OK
// ECDSA
{
"success": true,
"status": "SUCCESS",
"response_time_ms": "171",
"reference": "<your unique id>",
"wallet": {
"wallet_id": "37d7d51f-2f3a-4f16-9003-41366218a74c",
"nickname": "my_wallet_nickname",
"default": false
},
"is_whitelisted": true,
"available_balance": 300,
"pending_balance": 0,
}
// Authentication Tokens
{
"success": true,
"reference": "<your unique id>",
"wallet": {
"default": true
},
"is_whitelisted": true,
"available_balance": 0,
"pending_balance": 0,
"status": "SUCCESS",
"response_time_ms": "49"
}
const res = await Sila.getWallet(userHandle, walletPrivateKey);
// Success Response Object
console.log(res.statusCode); // 200
console.log(res.data.reference);
console.log(res.data.success); // TRUE
console.log(res.data.status);
console.log(res.data.is_whitelisted); // Indicates if the wallet is able to perform transactions
console.log(res.data.sila_available_balance); // new field for sila_balance
console.log(res.data.sila_pending_balance); // new field for sila_balance
console.log(res.data.wallet);
console.log(res.data.wallet.statements_enabled);
console.log(res.data.wallet.nickname);
console.log(res.data.wallet.default);
console.log(res.data.wallet.blockchain_address);
console.log(res.data.wallet.blockchain_network);
payload = {
"user_handle": "user.silamoney.eth"
}
response = Wallet.getWallet(app, payload, user_private_key)
### Success Response Object
{
"status": 'SUCCESS',
"status_code": 200,
"success": True,
"reference": "ref",
"wallet": {
"nickname": "my_wallet_nickname",
"default": False,
"blockchain_address": "0x...",
"blockchain_network": "ETH"
},
"is_whitelisted": True,
"sila_balance": 300.0,
"sila_available_balance": 300,
"sila_pending_balance": 0
}
### Failure Response Object
{
"success": False,
"reference": "ref",
"message": "Error message"
}
ApiResponse response = api.getWallet(userHandle, userPrivateKey);
GetWalletResponse parsedResponse = (GetWalletResponse) response.getData();
// Success Response Object
System.out.println(response.getStatusCode()); // 200
System.out.println(parsedResponse.getSuccess());
System.out.println(parsedResponse.getStatus());
System.out.println(parsedResponse.getReference());
System.out.println(parsedResponse.getWallet()); // Wallet object
System.out.println(parsedResponse.getWallet().getBlockChainAddress());
System.out.println(parsedResponse.getWallet().getBlockChainNetwork());
System.out.println(parsedResponse.getWallet().getWalletId());
System.out.println(parsedResponse.getWallet().getPrivateKey());
System.out.println(parsedResponse.getWallet().getNickname());
System.out.println(parsedResponse.getWallet().isDefaultWallet());
System.out.println(parsedResponse.getWallet().isFrozen());
System.out.println(parsedResponse.getWallet().getWalletId());
System.out.println(parsedResponse.getWallet().isStatementsEnabled()); // Boolean
System.out.println(parsedResponse.isWhitelisted()); // Boolean
System.out.println(parsedResponse.getSilaBalance()); // Sila balance
System.out.println(parsedResponse.getSilaAvailableBalance()); // Sila available balance
System.out.println(parsedResponse.getSilaPendingBalance()); // Sila pending balance
$userHandle = 'user.silamoney.eth';
$userPrivateKey = 'some private key'; // Hex format
// Call the api
$response = $client->getWallet($userHandle, $userPrivateKey);
// Success 200
echo $response->getStatusCode(); // 200
echo $response->getData()->status;
echo $response->getData()->success; // TRUE
echo $response->getData()->reference; // Random reference number
echo $response->getData()->wallet; // The wallet requested
echo $response->getData()->is_whitelisted; // Indicates if the wallet is whitelisted
echo $response->getData()->sila_balance; // The current sila balance of the wallet.
echo $response->getData()->sila_balance; // The current sila balance of the wallet.
echo $response->getData()->sila_available_balance;
echo $response->getData()->sila_pending_balance;
echo $response->getData()->wallet->statements_enabled;
ApiResponse<object> response = api.GetWallet(userHandle, walletPrivateKey);
// Success Object Response
Console.WriteLine(response.StatusCode); // 200
var parsedData = (SingleWalletResponse)response.Data;
Console.WriteLine(parsedData.Success); // TRUE
Console.WriteLine(parsedData.Reference); // Reference
Console.WriteLine(parsedData.IsWhitelisted); // Is Whitelisted?
Console.WriteLine(parsedData.SilaBalance); // # of Sila tokens
Console.WriteLine(parsedData.Wallet); // Wallet details (nickname, default...)
Console.WriteLine(parsedData.Wallet.WalletId); // wallet_id "37d7d51f-2f3a-4f16-9003-41366218a74c"
Console.WriteLine(parsedData.SilaAvailableBalance); // 300
Console.WriteLine(parsedData.SilaPendingBalance); // 0
Key | Type | Description |
---|---|---|
header | JSON object | Required. Requires these keys in JSON format: created, app_handle, user_handle. See the /check_handle endpoint for the complete list of fields in this object. |
wallet_id | string | Optional; only used by AuthToken apps to specify which wallet if necessary. |
nickname | string | Optional: only used by AuthToken apps to specify which wallet if necessary. |
Responses
The success attribute is a JSON key sent in the response body.
Status Code | success Attribute | Description |
---|---|---|
200 | true | Successfully fetched and returned wallet. |
400 | false | Bad request format. |
403 | false | Auth signature is absent or derived address does not belong to app_handle. |
500 | false | Temporarily unable to check contract for whitelisting and balance details (see response message for details). |
Updated about 2 months ago