Skip to main content

Crate trident_sdk

Crate trident_sdk 

Source
Expand description

§trident-sdk

End-user SDK for depositing into Trident and executing cross-chain spends through the Trident delivery service.

TridentClient covers the common user flow. The crate also exposes lower-level EVM bindings and protobuf types for applications that need direct contract reads, revert decoding, custom signing, or raw gRPC access.

§Scope

  • Build a TridentClient by registering per-domain chains
  • Prepare and submit deposits
  • Submit spend intents through the delivery service and execute returned attestations
  • Access curated spender/depositor EVM bindings under evm::abi
  • Access EIP-712 spend-intent signing helpers under evm::signing
  • Access generated protobuf messages and gRPC client types under proto

§Current support

  • EVM chain handlers today
  • ChainAddress is the SDK’s chain-agnostic address trait and is implemented for alloy_primitives::Address today
  • Domain values are Trident domain identifiers, not raw chain IDs

§Typical flow

  1. Build a TridentClient with TridentClientBuilder and register the domains you want to use.
  2. Call deposit to prepare a source-chain deposit, then Deposit::send to submit it.
  3. Build a SpendRequestBuilder and call spend.
  4. Submit the returned SpendAttestation on the destination chain with SpendAttestation::send.

deposit prepares a source-chain deposit into the domain’s Trident deposit contract. Deposit::send submits the on-chain transaction and automatically approves the deposit contract first if the current ERC-20 allowance is too low.

spend builds a spend intent, fills in the source spender, Trident contract addresses, random salt, and, unless explicitly set on the builder, the max fee and expiry height. It signs the intent, submits it to the delivery service, and returns a SpendAttestation.

§Examples

Keep runnable examples in examples/ rather than turning this README into a tutorial.

Current examples:

  • deposit_evm.rs: build a client for one EVM domain, prepare a deposit, and submit it
  • spend_evm.rs: build a client across two EVM domains, submit a spend, and relay the returned attestation
  • balance_semantics.rs: compare TridentClient::get_balance with on-chain TridentDeposits::depositedAmount

§Balance semantics

TridentClient::get_balance returns the delivery-service balance tracked by Trident for an account, domain, and token.

That is not the same value as evm::abi::TridentDeposits::depositedAmount, which reads the source-side on-chain bookkeeping balance in the TridentDeposits contract. Applications often need both views, but they should not be treated as interchangeable.

§Lower-level modules

Use evm::abi for curated spender/depositor contract bindings, events, errors, and direct reads such as TridentDeposits::depositedAmount or attestation validation helpers.

Use evm::signing for Trident’s EIP-712 spend-intent signing logic outside TridentClient.

Use proto for the raw generated protobuf messages and gRPC client types.

§Notes

  • Token amounts are expressed in the token’s atomic units.
  • SpendRequestBuilder lets callers override the auto-resolved max fee, expiry height, and destination caller.

Modules§

evm
Lower-level EVM bindings and signature utilities for Trident integrations.
proto
Raw generated protobuf messages and gRPC client types. Generated protobuf messages and gRPC client types used by trident-sdk.

Structs§

Balance
Deposit
A prepared deposit ready to be submitted on-chain.
EvmCallContext
Raw pieces needed to execute the tridentSpend call against a Trident delivery contract.
MulticallBuilder
Accumulator for a Multicall3 batch to be run via a self-call into a 7702-delegated TridentAccount EOA.
SpendAttestation
A spend attestation ready to be executed on-chain.
SpendMulticall
A MulticallBuilder seeded with a Trident spend, carrying the attestation’s provider so .send() doesn’t need one passed in.
SpendRequestBuilder
Configures a cross-chain spend request.
TridentClient
Client for the Trident cross-chain delivery service.
TridentClientBuilder
Builds a TridentClient by registering one chain-handler builder per domain and connecting to the delivery service.

Enums§

TridentClientBuilderError
Errors returned while building and connecting a TridentClient.
TridentClientError
Errors returned by TridentClient operations.

Traits§

ChainAddress
A chain-agnostic address trait used by the SDK’s cross-chain request APIs.

Type Aliases§

Domain
Trident domain identifier for a supported source or destination chain.