Managing Accounts
An Account
represents a financial account linked to an Entity
, such as a brokerage account, a blockchain wallet for stocks, etc. The following sections provide an example on how to manage accounts on an entity. Please note that to manage your organization, use the entity id provided in your dashboard.
SDK Reference
SDK Examples
Creating an Account
import Dinari from '@dinari/api-sdk';
const client = new Dinari({
apiKeyID: process.env['DINARI_API_KEY_ID'], // This is the default and can be omitted
apiSecretKey: process.env['DINARI_API_SECRET_KEY'], // This is the default and can be omitted
environment: 'sandbox', // defaults to 'production'
});
async function main() {
const entity = await client.v2.entities.create({
name: 'Jane Doe',
});
const account = await client.v2.entities.accounts.create(entity.id);
console.log(account);
}
main();
import os
from dinari_api_sdk import Dinari
client = Dinari(
api_key_id=os.environ.get("DINARI_API_KEY_ID"), # This is the default and can be omitted
api_secret_key=os.environ.get("DINARI_API_SECRET_KEY"), # This is the default and can be omitted
environment="sandbox", # defaults to "production"
)
entity = client.v2.entities.create(
name="Jane Doe",
)
account = client.v2.entities.accounts.create(
entity_id=entity.id,
)
package main
import (
"context"
"fmt"
"log"
dinari "github.com/dinaricrypto/dinari-api-sdk-go"
"github.com/dinaricrypto/dinari-api-sdk-go/option"
)
func main() {
// DINARI_API_KEY_ID and DINARI_API_SECRET_KEY are set as environment variables
client := dinari.NewClient(
option.WithEnvironmentSandbox(), // Defaults to production when omitted
)
params := dinari.V2EntityNewParams{
Name: "Jane Doe",
}
newEntity, err := client.V2.Entities.New(context.TODO(), params)
if err != nil {
log.Fatalf("Failed to create entity: %v", err)
}
account, err := client.V2.Entities.Accounts.New(context.TODO(), newEntity.ID)
if err != nil {
log.Fatalf("Failed to create account: %v", err)
}
fmt.Printf("Account ID: %+v\\n", account.ID)
}
Adding Wallet to an Account
import Dinari from '@dinari/api-sdk';
const client = new Dinari({
apiKeyID: process.env['DINARI_API_KEY_ID'], // This is the default and can be omitted
apiSecretKey: process.env['DINARI_API_SECRET_KEY'], // This is the default and can be omitted
environment: 'sandbox', // defaults to 'production'
});
async function main() {
const accountID = 'your-account-id';
const walletAddress = 'your-wallet-address';
// Step 1: Get the nonce message to sign
const nonceResp = await client.v2.accounts.wallet.external.getNonce(accountID, {
wallet_address: walletAddress,
});
// Step 2: Sign the message (replace this with actual off-chain signing)
const signature = 'your-wallet-signature'; // Sign nonceResp.message with the wallet
// Step 3: Connect the wallet using the signed message
const linkedWallet = await client.v2.accounts.wallet.external.connect(accountID, {
chain_id: 'eip155:1',
nonce: nonceResp.nonce,
signature,
wallet_address: walletAddress,
});
console.log(linkedWallet);
}
main();
import os
from dinari_api_sdk import Dinari
client = Dinari(
api_key_id=os.environ.get("DINARI_API_KEY_ID"), # This is the default and can be omitted
api_secret_key=os.environ.get("DINARI_API_SECRET_KEY"), # This is the default and can be omitted
environment="sandbox", # defaults to "production"
)
account_id = "your-account-id"
wallet_address = "your-wallet-address"
# Step 1: Get the nonce message to sign
nonce_resp = client.v2.accounts.wallet.external.get_nonce(
account_id=account_id,
wallet_address=wallet_address,
)
# Step 2: Sign the message (replace this with actual off-chain signing)
signature = "your-wallet-signature" # Sign nonce_resp.message with the wallet
# Step 3: Connect the wallet using the signed message
linked_wallet = client.v2.accounts.wallet.external.connect(
account_id=account_id,
chain_id="eip155:1",
nonce=nonce_resp.nonce,
signature=signature,
wallet_address=wallet_address,
)
package main
import (
"context"
"fmt"
"log"
dinari "github.com/dinaricrypto/dinari-api-sdk-go"
"github.com/dinaricrypto/dinari-api-sdk-go/option"
)
func main() {
// DINARI_API_KEY_ID and DINARI_API_SECRET_KEY are set as environment variables
client := dinari.NewClient(
option.WithEnvironmentSandbox(), // Defaults to production when omitted
)
accountID := "your-account-id"
walletAddress := "your-wallet-address"
// Step 1: Get the nonce message to sign
externalWalletResp, err := client.V2.Accounts.Wallet.External.GetNonce(context.TODO(), accountID, dinari.V2AccountWalletExternalGetNonceParams{
WalletAddress: walletAddress,
})
if err != nil {
log.Fatalf("Failed to get wallet nonce: %v", err)
}
// Step 2: Sign the message (this part is mocked for now)
signature := "your-wallet-signature" // You'd sign externalWalletResp.Message off-chain
// Step 3: Connect the wallet using the signed message
linkedWallet, err := client.V2.Accounts.Wallet.External.Connect(context.TODO(), accountID, dinari.V2AccountWalletExternalConnectParams{
ChainID: dinari.ChainEip155_1,
Nonce: externalWalletResp.Nonce,
Signature: signature,
WalletAddress: walletAddress,
})
if err != nil {
log.Fatalf("Failed to connect external wallet: %v", err)
}
fmt.Printf("Linked Wallet: %+v\n", linkedWallet)
}
Customer Wallets
Managed Wallets
This will only work on your organization's accounts
Updated 19 days ago