Building with SettleMint/SDK Developer Guide

Viem

Integrating Viem for Ethereum interactions in your SettleMint dApp

About

The SettleMint Viem SDK provides a lightweight wrapper that automatically configures and sets up a Viem client based on your connected SettleMint application. It simplifies the process of establishing connections to SettleMint-managed blockchain networks by handling authentication, endpoint configuration, and chain selection. This allows developers to quickly start using Viem's powerful Ethereum interaction capabilities without manual setup, while ensuring proper integration with the SettleMint platform.

API Reference

Functions

getPublicClient()

getPublicClient(options): object

Defined in: sdk/viem/src/viem.ts:64

Get a public client. Use this if you need to read from the blockchain.

Parameters
ParameterTypeDescription
optionsClientOptionsThe options for the public client.
Returns

object

The public client. see https://viem.sh/docs/clients/public

Example
import { getPublicClient } from '@settlemint/sdk-viem';
 
const publicClient = getPublicClient({
  accessToken: process.env.SETTLEMINT_ACCESS_TOKEN!,
  chainId: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!,
  chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,
  rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,
});
 
// Get the block number
const block = await publicClient.getBlockNumber();
console.log(block);

getWalletClient()

getWalletClient(options): (verificationOptions?) => Client<HttpTransport<undefined | RpcSchema, boolean>, Chain, undefined, WalletRpcSchema, object & object & object & object & object & object & object & WalletActions<Chain, undefined>>

Defined in: sdk/viem/src/viem.ts:126

Get a wallet client. Use this if you need to write to the blockchain.

Parameters
ParameterTypeDescription
optionsClientOptionsThe options for the wallet client.
Returns

A function that returns a wallet client. The function can be called with verification options for HD wallets. see https://viem.sh/docs/clients/wallet

(verificationOptions?): Client<HttpTransport<undefined | RpcSchema, boolean>, Chain, undefined, WalletRpcSchema, object & object & object & object & object & object & object & WalletActions<Chain, undefined>>

Parameters
ParameterType
verificationOptions?WalletVerificationOptions
Returns

Client<HttpTransport<undefined | RpcSchema, boolean>, Chain, undefined, WalletRpcSchema, object & object & object & object & object & object & object & WalletActions<Chain, undefined>>

Example
import { getWalletClient } from '@settlemint/sdk-viem';
import { parseAbi } from "viem";
 
const walletClient = getWalletClient({
  accessToken: process.env.SETTLEMINT_ACCESS_TOKEN!,
  chainId: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!,
  chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,
  rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,
});
 
// Get the chain id
const chainId = await walletClient().getChainId();
console.log(chainId);
 
// write to the blockchain
const transactionHash = await walletClient().writeContract({
  account: "0x0000000000000000000000000000000000000000",
  address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
  abi: parseAbi(["function mint(uint32 tokenId) nonpayable"]),
  functionName: "mint",
  args: [69420],
});
console.log(transactionHash);

Enumerations

OTPAlgorithm

Defined in: sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:18

Supported hash algorithms for One-Time Password (OTP) verification. These algorithms determine the cryptographic function used to generate OTP codes.

Enumeration Members
Enumeration MemberValueDescriptionDefined in
SHA1"SHA1"SHA-1 hash algorithmsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:20
SHA224"SHA224"SHA-224 hash algorithmsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:22
SHA256"SHA256"SHA-256 hash algorithmsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:24
SHA3_224"SHA3-224"SHA3-224 hash algorithmsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:30
SHA3_256"SHA3-256"SHA3-256 hash algorithmsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:32
SHA3_384"SHA3-384"SHA3-384 hash algorithmsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:34
SHA3_512"SHA3-512"SHA3-512 hash algorithmsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:36
SHA384"SHA384"SHA-384 hash algorithmsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:26
SHA512"SHA512"SHA-512 hash algorithmsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:28

WalletVerificationType

Defined in: sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:5

Types of wallet verification methods supported by the system. Used to identify different verification mechanisms when creating or managing wallet verifications.

Enumeration Members
Enumeration MemberValueDescriptionDefined in
OTP"OTP"One-Time Password verification methodsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:9
PINCODE"PINCODE"PIN code verification methodsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:7
SECRET_CODES"SECRET_CODES"Secret recovery codes verification methodsdk/viem/src/custom-actions/types/wallet-verification.enum.ts:11

Interfaces

ClientOptions

Defined in: sdk/viem/src/viem.ts:21

The options for the viem client.

Properties
PropertyTypeDescriptionDefined in
accessTokenstringThe access tokensdk/viem/src/viem.ts:25
chainIdstringThe chain idsdk/viem/src/viem.ts:29
chainNamestringThe chain namesdk/viem/src/viem.ts:33
httpTransportConfig?HttpTransportConfigThe http transport configsdk/viem/src/viem.ts:41
rpcUrlstringThe json rpc urlsdk/viem/src/viem.ts:37

CreateWalletParameters

Defined in: sdk/viem/src/custom-actions/create-wallet.action.ts:14

Parameters for creating a wallet.

Properties
PropertyTypeDescriptionDefined in
keyVaultIdstringThe unique name of the key vault where the wallet will be created.sdk/viem/src/custom-actions/create-wallet.action.ts:16
walletInfoWalletInfoInformation about the wallet to be created.sdk/viem/src/custom-actions/create-wallet.action.ts:18

CreateWalletResponse

Defined in: sdk/viem/src/custom-actions/create-wallet.action.ts:24

Response from creating a wallet.

Properties
PropertyTypeDescriptionDefined in
addressstringThe blockchain address of the wallet.sdk/viem/src/custom-actions/create-wallet.action.ts:30
derivationPathstringThe HD derivation path used to create the wallet.sdk/viem/src/custom-actions/create-wallet.action.ts:32
idstringThe unique identifier of the wallet.sdk/viem/src/custom-actions/create-wallet.action.ts:26
namestringThe name of the wallet.sdk/viem/src/custom-actions/create-wallet.action.ts:28

CreateWalletVerificationChallengesParameters

Defined in: sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:8

Parameters for creating wallet verification challenges.

Properties
PropertyTypeDescriptionDefined in
addressOrObjectAddressOrObjectThe wallet address or object containing wallet address and optional verification ID.sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:10

CreateWalletVerificationParameters

Defined in: sdk/viem/src/custom-actions/create-wallet-verification.action.ts:59

Parameters for creating a wallet verification.

Properties
PropertyTypeDescriptionDefined in
userWalletAddressstringThe wallet address for which to create the verification.sdk/viem/src/custom-actions/create-wallet-verification.action.ts:61
walletVerificationInfoWalletVerificationInfoThe verification information to create.sdk/viem/src/custom-actions/create-wallet-verification.action.ts:63

CreateWalletVerificationResponse

Defined in: sdk/viem/src/custom-actions/create-wallet-verification.action.ts:69

Response from creating a wallet verification.

Properties
PropertyTypeDescriptionDefined in
idstringThe unique identifier of the verification.sdk/viem/src/custom-actions/create-wallet-verification.action.ts:71
namestringThe name of the verification method.sdk/viem/src/custom-actions/create-wallet-verification.action.ts:73
parametersRecord<string, string>Additional parameters specific to the verification type.sdk/viem/src/custom-actions/create-wallet-verification.action.ts:77
verificationTypeWalletVerificationTypeThe type of verification method.sdk/viem/src/custom-actions/create-wallet-verification.action.ts:75

DeleteWalletVerificationParameters

Defined in: sdk/viem/src/custom-actions/delete-wallet-verification.action.ts:6

Parameters for deleting a wallet verification.

Properties
PropertyTypeDescriptionDefined in
userWalletAddressstringThe wallet address for which to delete the verification.sdk/viem/src/custom-actions/delete-wallet-verification.action.ts:8
verificationIdstringThe unique identifier of the verification to delete.sdk/viem/src/custom-actions/delete-wallet-verification.action.ts:10

DeleteWalletVerificationResponse

Defined in: sdk/viem/src/custom-actions/delete-wallet-verification.action.ts:16

Response from deleting a wallet verification.

Properties
PropertyTypeDescriptionDefined in
successbooleanWhether the deletion was successful.sdk/viem/src/custom-actions/delete-wallet-verification.action.ts:18

GetWalletVerificationsParameters

Defined in: sdk/viem/src/custom-actions/get-wallet-verifications.action.ts:7

Parameters for getting wallet verifications.

Properties
PropertyTypeDescriptionDefined in
userWalletAddressstringThe wallet address for which to fetch verifications.sdk/viem/src/custom-actions/get-wallet-verifications.action.ts:9

VerificationResult

Defined in: sdk/viem/src/custom-actions/verify-wallet-verification-challenge.action.ts:26

Result of a wallet verification challenge.

Properties
PropertyTypeDescriptionDefined in
verifiedbooleanWhether the verification was successful.sdk/viem/src/custom-actions/verify-wallet-verification-challenge.action.ts:28

VerifyWalletVerificationChallengeParameters

Defined in: sdk/viem/src/custom-actions/verify-wallet-verification-challenge.action.ts:16

Parameters for verifying a wallet verification challenge.

Properties
PropertyTypeDescriptionDefined in
addressOrObjectAddressOrObjectThe wallet address or object containing wallet address and optional verification ID.sdk/viem/src/custom-actions/verify-wallet-verification-challenge.action.ts:18
challengeResponsestringThe response to the verification challenge.sdk/viem/src/custom-actions/verify-wallet-verification-challenge.action.ts:20

WalletInfo

Defined in: sdk/viem/src/custom-actions/create-wallet.action.ts:6

Information about the wallet to be created.

Properties
PropertyTypeDescriptionDefined in
namestringThe name of the wallet.sdk/viem/src/custom-actions/create-wallet.action.ts:8

WalletOTPVerificationInfo

Defined in: sdk/viem/src/custom-actions/create-wallet-verification.action.ts:27

Information for One-Time Password (OTP) verification.

Extends
  • BaseWalletVerificationInfo
Properties
PropertyTypeDescriptionOverridesInherited fromDefined in
algorithm?OTPAlgorithmThe hash algorithm to use for OTP generation.--sdk/viem/src/custom-actions/create-wallet-verification.action.ts:31
digits?numberThe number of digits in the OTP code.--sdk/viem/src/custom-actions/create-wallet-verification.action.ts:33
issuer?stringThe issuer of the OTP.--sdk/viem/src/custom-actions/create-wallet-verification.action.ts:37
namestringThe name of the verification method.-BaseWalletVerificationInfo.namesdk/viem/src/custom-actions/create-wallet-verification.action.ts:9
period?numberThe time period in seconds for OTP validity.--sdk/viem/src/custom-actions/create-wallet-verification.action.ts:35
verificationTypeOTPThe type of verification method.BaseWalletVerificationInfo.verificationType-sdk/viem/src/custom-actions/create-wallet-verification.action.ts:29

WalletPincodeVerificationInfo

Defined in: sdk/viem/src/custom-actions/create-wallet-verification.action.ts:17

Information for PIN code verification.

Extends
  • BaseWalletVerificationInfo
Properties
PropertyTypeDescriptionOverridesInherited fromDefined in
namestringThe name of the verification method.-BaseWalletVerificationInfo.namesdk/viem/src/custom-actions/create-wallet-verification.action.ts:9
pincodestringThe PIN code to use for verification.--sdk/viem/src/custom-actions/create-wallet-verification.action.ts:21
verificationTypePINCODEThe type of verification method.BaseWalletVerificationInfo.verificationType-sdk/viem/src/custom-actions/create-wallet-verification.action.ts:19

WalletSecretCodesVerificationInfo

Defined in: sdk/viem/src/custom-actions/create-wallet-verification.action.ts:43

Information for secret recovery codes verification.

Extends
  • BaseWalletVerificationInfo
Properties
PropertyTypeDescriptionOverridesInherited fromDefined in
namestringThe name of the verification method.-BaseWalletVerificationInfo.namesdk/viem/src/custom-actions/create-wallet-verification.action.ts:9
verificationTypeSECRET_CODESThe type of verification method.BaseWalletVerificationInfo.verificationType-sdk/viem/src/custom-actions/create-wallet-verification.action.ts:45

WalletVerification

Defined in: sdk/viem/src/custom-actions/get-wallet-verifications.action.ts:15

Represents a wallet verification.

Properties
PropertyTypeDescriptionDefined in
idstringThe unique identifier of the verification.sdk/viem/src/custom-actions/get-wallet-verifications.action.ts:17
namestringThe name of the verification method.sdk/viem/src/custom-actions/get-wallet-verifications.action.ts:19
verificationTypeWalletVerificationTypeThe type of verification method.sdk/viem/src/custom-actions/get-wallet-verifications.action.ts:21

WalletVerificationChallenge

Defined in: sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:16

Represents a wallet verification challenge.

Properties
PropertyTypeDescriptionDefined in
challengeRecord<string, string>The challenge parameters specific to the verification type.sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:24
idstringThe unique identifier of the challenge.sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:18
namestringThe name of the challenge.sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:20
verificationTypeWalletVerificationTypeThe type of verification required.sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:22

WalletVerificationOptions

Defined in: sdk/viem/src/viem.ts:84

The options for the wallet client.

Properties
PropertyTypeDescriptionDefined in
challengeResponsestringThe challenge response (used for HD wallets)sdk/viem/src/viem.ts:92
verificationId?stringThe verification id (used for HD wallets), if not provided, the challenge response will be validated against all active verifications.sdk/viem/src/viem.ts:88

Type Aliases

AddressOrObject

AddressOrObject = string | { userWalletAddress: string; verificationId?: string; }

Defined in: sdk/viem/src/custom-actions/verify-wallet-verification-challenge.action.ts:6

Represents either a wallet address string or an object containing wallet address and optional verification ID.


CreateWalletVerificationChallengesResponse

CreateWalletVerificationChallengesResponse = WalletVerificationChallenge[]

Defined in: sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:30

Response from creating wallet verification challenges.


GetWalletVerificationsResponse

GetWalletVerificationsResponse = WalletVerification[]

Defined in: sdk/viem/src/custom-actions/get-wallet-verifications.action.ts:27

Response from getting wallet verifications.


VerifyWalletVerificationChallengeResponse

VerifyWalletVerificationChallengeResponse = VerificationResult[]

Defined in: sdk/viem/src/custom-actions/verify-wallet-verification-challenge.action.ts:34

Response from verifying a wallet verification challenge.


WalletVerificationInfo

WalletVerificationInfo = WalletPincodeVerificationInfo | WalletOTPVerificationInfo | WalletSecretCodesVerificationInfo

Defined in: sdk/viem/src/custom-actions/create-wallet-verification.action.ts:51

Union type of all possible wallet verification information types.

Contributing

We welcome contributions from the community! Please check out our Contributing guide to learn how you can help improve the SettleMint SDK through bug reports, feature requests, documentation updates, or code contributions.

License

The SettleMint SDK is released under the FSL Software License. See the LICENSE file for more details.