### Install Dinari API SDKs Source: https://docs.dinari.com/index Instructions for installing the Dinari API SDKs in different programming languages. Choose the library that matches your development environment. ```javascript npm install @dinari/api-sdk # or yarn add @dinari/api-sdk ``` ```python pip install dinari-api-sdk ``` ```go go get github.com/dinaricrypto/dinari-api-sdk-go ``` -------------------------------- ### Install Dinari API SDKs Source: https://docs.dinari.com/docs/quickstart Instructions for installing the Dinari API SDKs in different programming languages. Choose the library that matches your development environment. ```javascript npm install @dinari/api-sdk # or yarn add @dinari/api-sdk ``` ```python pip install dinari-api-sdk ``` ```go go get github.com/dinaricrypto/dinari-api-sdk-go ``` -------------------------------- ### Install Dinari API SDKs Source: https://docs.dinari.com/docs Instructions for installing the Dinari API SDKs in different programming languages. Choose the library that matches your development environment. ```javascript npm install @dinari/api-sdk # or yarn add @dinari/api-sdk ``` ```python pip install dinari-api-sdk ``` ```go go get github.com/dinaricrypto/dinari-api-sdk-go ``` -------------------------------- ### Prepare and Send Stock Order with Viem (TypeScript) Source: https://docs.dinari.com/docs/placing-dshare-orders Demonstrates initializing the Dinari client, preparing a stock order via the API, and then signing/sending the transaction data using Viem's WalletClient. This example assumes a frontend environment where the user can sign transactions. ```TypeScript import Dinari from '@dinari/api-sdk'; import { createWalletClient, createPublicClient, custom, http, WalletClient } from 'viem'; // See TS:viem-client tab import { resolveViemChain, sendOrderForViem } from './viem-client'; 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() { // Step 1. Prepare the Order const accountId = 'your-account-id'; const caip2ChainId = 'eip155:421614'; const preparedOrder = await client.v2.accounts.orders.stocks.eip155.prepareOrder(accountId, { chain_id: caip2ChainId, order_side: 'BUY', order_tif: 'DAY', order_type: 'MARKET', stock_id: '0196d545-d8a8-7210-8cd1-a49e82c31e53', payment_token: "0x6a34FDFE60D1758dF5b577d413E37397D21c3E78", payment_token_quantity: 10, }); // Step 2: Sign and send the transaction data using @dinari/viem-client (In Development) // If done in front end environment user will be prompted to sign each transaction. const viemChain = resolveViemChain(caip2ChainId); const walletClient = createWalletClient({ transport: custom((window as any).ethereum), chain: viemChain }); const txHashes = await sendOrderForViem(walletClient, caip2ChainId, preparedOrder); } main(); ``` -------------------------------- ### Full Proxied Order Creation Flow (Go) Source: https://docs.dinari.com/docs/placing-dshare-orders This comprehensive Go example demonstrates the end-to-end process of creating a proxied order with Dinari. It includes initializing the Dinari client, preparing the order details, signing permit and order data using an Ethereum wallet via go-web3, and finally submitting the signed order to the Dinari API. Dependencies include dinari-api-sdk-go and go-web3. ```go package main import ( "context" "encoding/hex" "encoding/json" "fmt" "log" "github.com/chenzhijie/go-web3" dinari "github.com/dinaricrypto/dinari-api-sdk-go" "github.com/dinaricrypto/dinari-api-sdk-go/option" "github.com/ethereum/go-ethereum/signer/core/apitypes" ) 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" // Step 1. Prepare the Proxied Order proxiedOrderParams := dinari.V2AccountOrderRequestStockEip155PrepareProxiedOrderParams{ ChainID: dinari.ChainEip155_421614, OrderSide: dinari.OrderSideBuy, OrderTif: dinari.OrderTifDay, OrderType: dinari.OrderTypeMarket, StockID: "0196d545-d8a8-7210-8cd1-a49e82c31e53", PaymentToken: dinari.String("0x6a34FDFE60D1758dF5b577d413E37397D21c3E78"), PaymentTokenQuantity: dinari.Float(1.0), } proxiedOrder, err := client.V2.Accounts.OrderRequests.Stocks.Eip155.PrepareProxiedOrder(context.TODO(), accountID, proxiedOrderParams) if err != nil { log.Fatalf("Failed: %v", err) } // Step 2. Sign Permit and Order Data var rpcProviderURL = "https://sepolia-rollup.arbitrum.io/rpc" w3, err := web3.NewWeb3(rpcProviderURL) if err != nil { panic(err) } privateKeyHex := "your-wallet-private-key" err = w3.Eth.SetAccount(privateKeyHex) if err != nil { panic(err) } permitSig, err := signTypedDataPayload(w3, DinariTypedData{ Domain: proxiedOrder.PermitTypedData.Domain, Message: proxiedOrder.PermitTypedData.Message, PrimaryType: proxiedOrder.PermitTypedData.PrimaryType, Types: proxiedOrder.PermitTypedData.Types, }) if err != nil { panic(err) } orderSig, err := signTypedDataPayload(w3, DinariTypedData{ Domain: proxiedOrder.OrderTypedData.Domain, Message: proxiedOrder.OrderTypedData.Message, PrimaryType: proxiedOrder.OrderTypedData.PrimaryType, Types: proxiedOrder.OrderTypedData.Types, }) if err != nil { panic(err) } // Step 3. Create Proxied Order with Permit and Order Data Signatures createBody := dinari.V2AccountOrderRequestStockEip155NewProxiedOrderParams{ OrderSignature: "0x" + hex.EncodeToString(orderSig), PermitSignature: "0x" + hex.EncodeToString(permitSig), PreparedProxiedOrderID: proxiedOrder.ID, } submittedProxiedOrder, err := client.V2.Accounts.OrderRequests.Stocks.Eip155.NewProxiedOrder(context.TODO(), accountID, createBody) if err != nil { log.Fatalf("Failed: %v", err) } fmt.Printf("Submitted Order: %+v\n", submittedProxiedOrder) } ``` -------------------------------- ### Dinari SDK Reference for KYC Source: https://docs.dinari.com/v2.0/docs/managing-kyc Provides links to SDK documentation for managing KYC processes. Each SDK offers specific methods and examples for integrating KYC functionality into your applications. ```APIDOC Dinari API KYC Management: This section provides access to the Dinari API documentation for managing Know Your Customer (KYC) and Know Your Business (KYB) requirements. Refer to the following SDK documentation for detailed API endpoints, methods, parameters, and examples: - Javascript / Typescript SDK: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md#kyc - Python SDK: https://github.com/dinaricrypto/dinari-api-sdk-python/blob/main/api.md#kyc - Go SDK: https://github.com/dinaricrypto/dinari-api-sdk-go/blob/main/api.md#kyc These resources detail how to submit, retrieve, and manage KYC/KYB status for your Dinari Entities. ``` -------------------------------- ### Dinari SDK Reference for KYC Source: https://docs.dinari.com/docs/managing-kyc Provides links to SDK documentation for managing KYC processes. Each SDK offers specific methods and examples for integrating KYC functionality into your applications. ```APIDOC Dinari API KYC Management: This section provides access to the Dinari API documentation for managing Know Your Customer (KYC) and Know Your Business (KYB) requirements. Refer to the following SDK documentation for detailed API endpoints, methods, parameters, and examples: - Javascript / Typescript SDK: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md#kyc - Python SDK: https://github.com/dinaricrypto/dinari-api-sdk-python/blob/main/api.md#kyc - Go SDK: https://github.com/dinaricrypto/dinari-api-sdk-go/blob/main/api.md#kyc These resources detail how to submit, retrieve, and manage KYC/KYB status for your Dinari Entities. ``` -------------------------------- ### Sandbox Faucet Request Examples Source: https://docs.dinari.com/reference/createaccountfaucet Examples demonstrating how to call the Sandbox Faucet API endpoint using different programming languages and shell commands. These examples assume appropriate authentication headers are set. ```Shell ACCOUNT_ID="your_account_id" API_URL="https://api-enterprise.sbt.dinari.com/api/v2/accounts/${ACCOUNT_ID}/faucet" curl -X POST ${API_URL} \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Content-Type: application/json" ``` ```Node.js const axios = require('axios'); const accountId = 'your_account_id'; const apiUrl = `https://api-enterprise.sbt.dinari.com/api/v2/accounts/${accountId}/faucet`; const accessToken = 'YOUR_ACCESS_TOKEN'; async function requestFaucet() { try { const response = await axios.post(apiUrl, {}, { headers: { 'Authorization': `Bearer ${accessToken}`, 'Content-Type': 'application/json' } }); console.log('Faucet request successful:', response.data); } catch (error) { console.error('Error requesting faucet:', error.response ? error.response.data : error.message); } } requestFaucet(); ``` ```Ruby require 'net/http' require 'uri' account_id = 'your_account_id' api_url = "https://api-enterprise.sbt.dinari.com/api/v2/accounts/#{account_id}/faucet" access_token = 'YOUR_ACCESS_TOKEN' uri = URI.parse(api_url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request['Authorization'] = "Bearer #{access_token}" request['Content-Type'] = 'application/json' response = http.request(request) puts "Status: #{response.code}" puts "Body: #{response.body}" ``` ```PHP ``` ```Python import requests account_id = 'your_account_id' api_url = f"https://api-enterprise.sbt.dinari.com/api/v2/accounts/{account_id}/faucet" access_token = 'YOUR_ACCESS_TOKEN' headers = { 'Authorization': f'Bearer {access_token}', 'Content-Type': 'application/json' } try: response = requests.post(api_url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes print(f"Response: {response.json()}") except requests.exceptions.RequestException as e: print(f"Error: {e}") ``` -------------------------------- ### Create Entity using Dinari SDKs (TypeScript, Python, Go) Source: https://docs.dinari.com/docs/entity-management Provides examples for creating an entity using the Dinari SDKs in TypeScript, Python, and Go. It shows how to initialize the client with API keys and environment settings, and then call the entity creation method. ```typescript 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: 'John Doe LLC', }); console.log(entity); } main(); ``` ```python 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="John Doe", ) ``` ```go 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: "Individual Name", } newEntity, err := client.V2.Entities.New(context.TODO(), params) if err != nil { log.Fatalf("Failed to create entity: %v", err) } fmt.Printf("New Entity ID: %+v\n", newEntity.ID) } ``` -------------------------------- ### Prepare Order on EVM using Client Libraries Source: https://docs.dinari.com/reference/createpreparedevmorder Examples demonstrating how to call the Dinari API to prepare an order on the EVM using different programming languages. These snippets show the basic structure for making the API request. ```Shell curl -X POST \ https://api-enterprise.sbt.dinari.com/api/v2/accounts/{account_id}/orders/stocks/eip155/prepare \ -H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' ``` ```Node.js const axios = require('axios'); const accountId = '{account_id}'; const accessToken = ''; axios.post(`https://api-enterprise.sbt.dinari.com/api/v2/accounts/${accountId}/orders/stocks/eip155/prepare`, {}, { headers: { 'Authorization': `Bearer ${accessToken}`, 'Content-Type': 'application/json' } }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error preparing order:', error); }); ``` ```Python import requests account_id = '{account_id}' access_token = '' url = f"https://api-enterprise.sbt.dinari.com/api/v2/accounts/{account_id}/orders/stocks/eip155/prepare" headers = { 'Authorization': f'Bearer {access_token}', 'Content-Type': 'application/json' } response = requests.post(url, headers=headers) if response.status_code == 200: print(response.json()) else: print(f"Error preparing order: {response.status_code} - {response.text}") ``` ```Ruby require 'httparty' account_id = '{account_id}' access_token = '' url = "https://api-enterprise.sbt.dinari.com/api/v2/accounts/#{account_id}/orders/stocks/eip155/prepare" response = HTTParty.post(url, headers: { 'Authorization' => "Bearer #{access_token}", 'Content-Type' => 'application/json' }) if response.code == 200 puts response.parsed_response else puts "Error preparing order: #{response.code} - #{response.body}" end ``` ```PHP '; $url = "https://api-enterprise.sbt.dinari.com/api/v2/accounts/{$accountId}/orders/stocks/eip155/prepare"; $headers = [ 'Authorization: Bearer ' . $accessToken, 'Content-Type: application/json' ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { echo $response; } curl_close($ch); ?> ``` -------------------------------- ### Go: Create Limit Buy Order Source: https://docs.dinari.com/docs/placing-dshare-orders Example of placing a limit buy order using the Dinari Go SDK. This function requires the account ID, stock ID, asset quantity, and the desired limit price. It attempts to buy the specified quantity of stock at or below the limit price. ```go limitBuyResp, err := client.V2.Accounts.OrderRequests.NewLimitBuy(context.TODO(), accountID, dinari.V2AccountOrderRequestNewLimitBuyParams{ CreateLimitOrderInput: dinari.CreateLimitOrderInputParam{ AssetQuantity: 1, LimitPrice: 1.5, StockID: stockID, }, }) if err != nil { log.Fatalf("Failed to create limit buy order: %v", err) } fmt.Printf("Limit Buy Response: %+v\n", limitBuyResp) ``` -------------------------------- ### Go: Create Market Buy Order Source: https://docs.dinari.com/docs/placing-dshare-orders Example of placing a market buy order using the Dinari Go SDK. This function requires the account ID and stock ID, along with the payment amount (in dollars) to spend. It buys the specified stock at the current market price. ```go marketBuyResp, err := client.V2.Accounts.OrderRequests.NewMarketBuy(context.TODO(), accountID, dinari.V2AccountOrderRequestNewMarketBuyParams{ PaymentAmount: 150.0, // This is the dollar amount to spend StockID: stockID, }) if err != nil { log.Fatalf("Failed to create market buy order: %v", err) } fmt.Printf("Market Buy Response: %+v\n", marketBuyResp) ``` -------------------------------- ### Go: Create Market Sell Order Source: https://docs.dinari.com/docs/placing-dshare-orders Example of placing a market sell order using the Dinari Go SDK. This function requires the account ID, stock ID, and the asset quantity to sell. It sells the specified quantity of stock at the current market price. ```go marketSellResp, err := client.V2.Accounts.OrderRequests.NewMarketSell(context.TODO(), accountID, dinari.V2AccountOrderRequestNewMarketSellParams{ AssetQuantity: 1, StockID: stockID, }) if err != nil { log.Fatalf("Failed to create market sell order: %v", err) } fmt.Printf("Market Sell Response: %+v\n", marketSellResp) ``` -------------------------------- ### Go: Create Limit Sell Order Source: https://docs.dinari.com/docs/placing-dshare-orders Example of placing a limit sell order using the Dinari Go SDK. This function requires the account ID, stock ID, asset quantity, and the desired limit price. It attempts to sell the specified quantity of stock at or above the limit price. ```go limitSellResp, err := client.V2.Accounts.OrderRequests.NewLimitSell(context.TODO(), accountID, dinari.V2AccountOrderRequestNewLimitSellParams{ CreateLimitOrderInput: dinari.CreateLimitOrderInputParam{ AssetQuantity: 1, LimitPrice: 1.5, StockID: stockID, }, }) if err != nil { log.Fatalf("Failed to create limit sell order: %v", err) } fmt.Printf("Limit Sell Response: %+v\n", limitSellResp) ``` -------------------------------- ### Fetch Stock News Examples Source: https://docs.dinari.com/reference/getstocknewsbystockid Examples demonstrating how to fetch stock news articles using the API across various programming languages. Each example shows the basic request structure, including the endpoint and necessary headers. ```Shell curl -X GET \ 'https://api-enterprise.sbt.dinari.com/api/v2/market_data/stocks/{stock_id}/news' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' ``` ```Node const axios = require('axios'); async function getStockNews(stockId) { const url = `https://api-enterprise.sbt.dinari.com/api/v2/market_data/stocks/${stockId}/news`; const headers = { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }; try { const response = await axios.get(url, { headers }); return response.data; } catch (error) { console.error('Error fetching stock news:', error); throw error; } } // Example usage: // getStockNews('AAPL').then(data => console.log(data)); ``` ```Ruby require 'httparty' class DinariApiClient def initialize(api_key) @api_key = api_key @base_url = 'https://api-enterprise.sbt.dinari.com/api/v2' end def get_stock_news(stock_id) url = "#{@base_url}/market_data/stocks/#{stock_id}/news" headers = { 'Authorization' => "Bearer #{@api_key}", 'Content-Type' => 'application/json' } HTTParty.get(url, headers: headers) end end # Example usage: # client = DinariApiClient.new('YOUR_API_KEY') # news = client.get_stock_news('MSFT') # puts news ``` ```PHP ``` ```Python import requests def get_stock_news(stock_id, api_key): url = f"https://api-enterprise.sbt.dinari.com/api/v2/market_data/stocks/{stock_id}/news" headers = { 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json' } try: response = requests.get(url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f"Error fetching stock news: {e}") return None # Example usage: # api_key = 'YOUR_API_KEY' # news = get_stock_news('TSLA', api_key) # if news: # print(news) ``` -------------------------------- ### Fetch Stock News (TypeScript, Python, Go) Source: https://docs.dinari.com/docs/stock-data Provides examples for retrieving news articles related to a specific stock using the Dinari API SDK. The code initializes the client and calls a method to fetch news, optionally allowing a limit on the number of articles returned. Requires Dinari API credentials and SDK installation. ```TypeScript 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 stockID = 'stock-id-here'; // Replace with the actual stock ID // Optionally specify a limit on the number of news articles returned const news = await client.v2.marketData.stocks.retrieveNews(stockID, { limit: 5 }); console.log(news); } main(); ``` ```Python 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" ) news = client.v2.market_data.stocks.retrieve_news( stock_id="stock_xxx", # Replace with the actual Stock ID limit=5, ) ``` ```Go 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 ) stockID := "target-stock-uuid" queryParams := dinari.V2MarketDataStockGetNewsParams{ Limit: dinari.Int(5), } news, err := client.V2.MarketData.Stocks.GetNews(context.TODO(), stockID, queryParams) if err != nil { log.Fatalf("Failed to get stock news: %v", err) } fmt.Printf("News: %+v\n", news) } ``` -------------------------------- ### Connect External Wallet (Go) Source: https://docs.dinari.com/v2.0/docs/managing-wallets Connects an external wallet to a Dinari account using a pre-signed message. This example demonstrates the full flow, including obtaining the nonce and then connecting the wallet. ```go 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) } ``` -------------------------------- ### Connect External Wallet (Go) Source: https://docs.dinari.com/docs/managing-wallets Connects an external wallet to a Dinari account using a pre-signed message. This example demonstrates the full flow, including obtaining the nonce and then connecting the wallet. ```go 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) } ``` -------------------------------- ### Fee Calculation Example Source: https://docs.dinari.com/docs/dshare-fees Illustrates how total fees are calculated based on trading fee, order fee, and the cost of the order. Volume-based discounts may apply. ```plaintext Total Fees = Trading Fee + (Order Fee * Cost of Order) Example: Cost of Order = $100 Trading Fee = $50 Order Fee = 0.005 (25 bps) Total Fees = 50 + (0.005 * 100) = 50.5 ``` -------------------------------- ### EVM dShare API SDK Usage Source: https://docs.dinari.com/docs/blockchain Details on how to retrieve a list of dShare addresses using the Dinari API SDK. This section is currently a placeholder and requires further implementation. ```APIDOC TODO: Detail out how to get list of dShare addresses using API SDK ``` -------------------------------- ### EVM dShare API SDK Usage Source: https://docs.dinari.com/docs/dshare-evm Details on how to retrieve a list of dShare addresses using the Dinari API SDK. This section is currently a placeholder and requires further implementation. ```APIDOC TODO: Detail out how to get list of dShare addresses using API SDK ``` -------------------------------- ### Dinari SDK Initialization and Order Preparation Source: https://docs.dinari.com/docs/placing-dshare-orders This Python snippet shows how to initialize the Dinari SDK with API credentials and environment settings. It then demonstrates preparing a stock order by specifying account details, chain, order parameters, and payment token information. ```Python import os from dinari_api_sdk import Dinari from eth_account import Account from eth_account.messages import encode_typed_data 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" private_key = "your-wallet-private-key" acct: LocalAccount = Account.from_key(private_key) # Step 1. Prepare Order order = client.v2.accounts.orders.stocks.eip155.prepare_order( account_id=account_id, chain_id="eip155:421614", order_side="BUY", order_tif="DAY", order_type="MARKET", stock_id="0196d545-d8a8-7210-8cd1-a49e82c31e53", payment_token="0x6a34FDFE60D1758dF5b577d413E37397D21c3E78", payment_token_quantity=1.0, ) ``` -------------------------------- ### Go: Initialize Dinari Client Source: https://docs.dinari.com/docs/placing-dshare-orders Shows how to initialize the Dinari Go client, optionally configuring it for a sandbox environment. The client uses environment variables for API keys and secrets. It's the first step before making any API calls. ```go client := dinari.NewClient( option.WithEnvironmentSandbox(), // Defaults to production when omitted ) ``` -------------------------------- ### Python: Dinari SDK - Prepare and Sign Order Source: https://docs.dinari.com/docs/placing-dshare-orders This Python script demonstrates how to use the Dinari SDK to prepare a proxied stock order and then sign the associated permit and order data using `eth_account`. It initializes the Dinari client, prepares an order, and generates signatures for both the permit and the order using a private key. ```Python import os from dinari_api_sdk import Dinari from eth_account import Account from eth_account.messages import encode_typed_data # Initialize Dinari client with API keys from environment variables client = Dinari( api_key_id=os.environ.get("DINARI_API_KEY_ID"), # Defaults to None if not set api_secret_key=os.environ.get("DINARI_API_SECRET_KEY"), # Defaults to None if not set environment="sandbox", # Can be "production" or "sandbox" ) account_id = "your-account-id" # Step 1. Prepare Proxied Order # This call prepares the necessary typed data for signing a stock order. proxied_order = client.v2.accounts.order_requests.stocks.eip155.prepare_proxied_order( account_id=account_id, chain_id="eip155:421614", # Example chain ID order_side="BUY", order_tif="DAY", order_type="MARKET", stock_id="0196d545-d8a8-7210-8cd1-a49e82c31e53", # Example stock ID payment_token="0x6a34FDFE60D1758dF5b577d413E37397D21c3E78", # Example payment token address payment_token_quantity=1.0, ) # Load wallet account from private key private_key = "your-wallet-private-key" acct = Account.from_key(private_key) # Step 2. Sign Order and permit typed data # Sign Permit Typed Data typed_data_permit = { "types": proxied_order.permit_typed_data.types, "domain": proxied_order.permit_typed_data.domain, "primaryType": proxied_order.permit_typed_data.primary_type, "message": proxied_order.permit_typed_data.message, } # Encode and sign the permit message message_permit = encode_typed_data(full_message=typed_data_permit) permit_signature = acct.sign_message(message_permit) # Sign Order Typed Data typed_data_order = { "types": proxied_order.order_typed_data.types, "domain": proxied_order.order_typed_data.domain, "primaryType": proxied_order.order_typed_data.primary_type, "message": proxied_order.order_typed_data.message, } # Encode and sign the order message message_order = encode_typed_data(full_message=typed_data_order) order_signature = acct.sign_message(message_order) # The permit_signature and order_signature can now be used to submit the order. print(f"Permit Signature: {permit_signature.signature.hex()}") print(f"Order Signature: {order_signature.signature.hex()}") ``` -------------------------------- ### Go: Prepare and Send Dinari Order Source: https://docs.dinari.com/docs/placing-dshare-orders This Go program initializes the Dinari API client, sets up the environment (e.g., sandbox), prepares a stock order with specified parameters, and then calls a function to send the transaction data using the go-web3 library. It handles client initialization and error checking. ```go package main import ( "context" "fmt" "log" "github.com/chenzhijie/go-web3" 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" // Step 1. Prepare Order prepareOrderBody := dinari.V2AccountOrderStockEip155PrepareOrderParams{ ChainID: dinari.ChainEip155_421614, OrderSide: dinari.OrderSideBuy, OrderTif: dinari.OrderTifDay, OrderType: dinari.OrderTypeMarket, StockID: "0196d545-d8a8-7210-8cd1-a49e82c31e53", PaymentToken: dinari.String("0x6a34FDFE60D1758dF5b577d413E37397D21c3E78"), PaymentTokenQuantity: dinari.Float(1.0), } preparedOrderResp, err := client.V2.Accounts.Orders.Stocks.Eip155.PrepareOrder(context.TODO(), accountID, prepareOrderBody) if err != nil { log.Fatalf("Failed: %v", err) } var rpcProviderURL = "https://sepolia-rollup.arbitrum.io/rpc" w3, err := web3.NewWeb3(rpcProviderURL) if err != nil { panic(err) } w3.Eth.SetChainId(421614) privateKey := "your-wallet-private-key" err = w3.Eth.SetAccount(privateKey) if err != nil { panic(err) } // Step 2. Send Order txHashes, err := SendOrder(context.TODO(), preparedOrderResp, w3) if err != nil { panic(err) } fmt.Printf("hashes: %+v\n", txHashes) } ```