Smart Contract Integration
The most important class for low-level operations with the Devol smart contract is DvlClient.
rpc_client
- standard RPC client from the Solana libraryint_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:
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 asget_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 toget_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 viarpc_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 typeDvlSendTransactionParams
with the following mandatory parameters:instructions
- a set of instructionssigner
- public key of the signersigner_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.