• rpc_client - standard RPC client from the Solana library
  • int_seed - unique branch number of the smart contract (for mainnet, this is 1)
  • admin_public_key - public key of the administrator (for mainnet, this is 7t13RqNfLcQMtdsGfo5rNoRE5REJyLzHbX8QuqEURbbJ)
  • program_id - address of the smart contract (for mainnet - DVL8i4TR4TxtPwpvK4UyVrxc7VWWRtRG74XmKQ6xXpfq)

Based on the provided data, the client can determine which specific smart contract it is interacting with and will allow reading accounts knowing only their type and sending transactions.

The general setup looks like this:

let rpc_client = RpcClient::new(String::from(RPC_URL));
let dvl_client = DvlClient::new(rpc_client, INT_SEED, ADMIN_PUBLIC_KEY, PROGRAM_ID);

DvlClient Methods

DvlClient offers three methods for working with accounts:

  • get_account - Makes a call to RPC, retrieves the account of the requested type, checks the data for correctness, and if all is well, returns the retrieved structure. If the required account depends on an upstream account in the account tree, recursive reading is performed. Thus, this method makes from one to several calls to RPC depending on the ” depth” of the account.

  • get_account_by_public_key - Does the same as get_account, but instead of recursive reading, it always makes exactly one request to RPC.

  • account_public_key - Returns the public key of the required account without reading its data. It works similarly to get_account in terms of the number of RPC calls but makes one less read since the target account is not retrieved.

Method for Sending Transactions:

  • send_transaction - Based on parameters specific to the transaction, it prepares and sends it via rpc_client. The method is provided “as it is”, and if it does not suit your needs, you may use your own. In the current implementation, the method accepts an object of type DvlSendTransactionParams with the following mandatory parameters:
    • instructions - a set of instructions
    • signer - public key of the signer
    • signer_fn - a function to sign the transaction before sending (we do not request the public key, only the function for signing)

Other parameters are optional and should be obvious from the context.