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
getChainId()
getChainId(
options
):Promise
<number
>
Defined in: sdk/viem/src/viem.ts:217
Get the chain id of a blockchain network.
Parameters
Parameter | Type | Description |
---|---|---|
options | GetChainIdOptions | The options for the public client. |
Returns
Promise
<number
>
The chain id.
Example
import { getChainId } from '@settlemint/sdk-viem';
const chainId = await getChainId({
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,
});
console.log(chainId);
getPublicClient()
getPublicClient(
options
):object
Defined in: sdk/viem/src/viem.ts:75
Get a public client. Use this if you need to read from the blockchain.
Parameters
Parameter | Type | Description |
---|---|---|
options | ClientOptions | The 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:143
Get a wallet client. Use this if you need to write to the blockchain.
Parameters
Parameter | Type | Description |
---|---|---|
options | ClientOptions | The 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
Parameter | Type |
---|---|
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 Member | Value | Description | Defined in |
---|---|---|---|
SHA1 | "SHA1" | SHA-1 hash algorithm | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:20 |
SHA224 | "SHA224" | SHA-224 hash algorithm | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:22 |
SHA256 | "SHA256" | SHA-256 hash algorithm | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:24 |
SHA3_224 | "SHA3-224" | SHA3-224 hash algorithm | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:30 |
SHA3_256 | "SHA3-256" | SHA3-256 hash algorithm | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:32 |
SHA3_384 | "SHA3-384" | SHA3-384 hash algorithm | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:34 |
SHA3_512 | "SHA3-512" | SHA3-512 hash algorithm | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:36 |
SHA384 | "SHA384" | SHA-384 hash algorithm | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:26 |
SHA512 | "SHA512" | SHA-512 hash algorithm | sdk/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 Member | Value | Description | Defined in |
---|---|---|---|
OTP | "OTP" | One-Time Password verification method | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:9 |
PINCODE | "PINCODE" | PIN code verification method | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:7 |
SECRET_CODES | "SECRET_CODES" | Secret recovery codes verification method | sdk/viem/src/custom-actions/types/wallet-verification.enum.ts:11 |
Interfaces
CreateWalletParameters
Defined in: sdk/viem/src/custom-actions/create-wallet.action.ts:14
Parameters for creating a wallet.
Properties
Property | Type | Description | Defined in |
---|---|---|---|
keyVaultId | string | The unique name of the key vault where the wallet will be created. | sdk/viem/src/custom-actions/create-wallet.action.ts:16 |
walletInfo | WalletInfo | Information 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
Property | Type | Description | Defined in |
---|---|---|---|
address | string | The blockchain address of the wallet. | sdk/viem/src/custom-actions/create-wallet.action.ts:30 |
derivationPath | string | The HD derivation path used to create the wallet. | sdk/viem/src/custom-actions/create-wallet.action.ts:32 |
id | string | The unique identifier of the wallet. | sdk/viem/src/custom-actions/create-wallet.action.ts:26 |
name | string | The 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
Property | Type | Description | Defined in |
---|---|---|---|
addressOrObject | AddressOrObject | The 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
Property | Type | Description | Defined in |
---|---|---|---|
userWalletAddress | string | The wallet address for which to create the verification. | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:61 |
walletVerificationInfo | WalletVerificationInfo | The 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
Property | Type | Description | Defined in |
---|---|---|---|
id | string | The unique identifier of the verification. | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:71 |
name | string | The name of the verification method. | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:73 |
parameters | Record <string , string > | Additional parameters specific to the verification type. | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:77 |
verificationType | WalletVerificationType | The 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
Property | Type | Description | Defined in |
---|---|---|---|
userWalletAddress | string | The wallet address for which to delete the verification. | sdk/viem/src/custom-actions/delete-wallet-verification.action.ts:8 |
verificationId | string | The 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
Property | Type | Description | Defined in |
---|---|---|---|
success | boolean | Whether 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
Property | Type | Description | Defined in |
---|---|---|---|
userWalletAddress | string | The 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
Property | Type | Description | Defined in |
---|---|---|---|
verified | boolean | Whether 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
Property | Type | Description | Defined in |
---|---|---|---|
addressOrObject | AddressOrObject | The wallet address or object containing wallet address and optional verification ID. | sdk/viem/src/custom-actions/verify-wallet-verification-challenge.action.ts:18 |
challengeResponse | string | The 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
Property | Type | Description | Defined in |
---|---|---|---|
name | string | The 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
Property | Type | Description | Overrides | Inherited from | Defined in |
---|---|---|---|---|---|
algorithm? | OTPAlgorithm | The hash algorithm to use for OTP generation. | - | - | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:31 |
digits? | number | The number of digits in the OTP code. | - | - | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:33 |
issuer? | string | The issuer of the OTP. | - | - | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:37 |
name | string | The name of the verification method. | - | BaseWalletVerificationInfo.name | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:9 |
period? | number | The time period in seconds for OTP validity. | - | - | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:35 |
verificationType | OTP | The 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
Property | Type | Description | Overrides | Inherited from | Defined in |
---|---|---|---|---|---|
name | string | The name of the verification method. | - | BaseWalletVerificationInfo.name | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:9 |
pincode | string | The PIN code to use for verification. | - | - | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:21 |
verificationType | PINCODE | The 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
Property | Type | Description | Overrides | Inherited from | Defined in |
---|---|---|---|---|---|
name | string | The name of the verification method. | - | BaseWalletVerificationInfo.name | sdk/viem/src/custom-actions/create-wallet-verification.action.ts:9 |
verificationType | SECRET_CODES | The 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
Property | Type | Description | Defined in |
---|---|---|---|
id | string | The unique identifier of the verification. | sdk/viem/src/custom-actions/get-wallet-verifications.action.ts:17 |
name | string | The name of the verification method. | sdk/viem/src/custom-actions/get-wallet-verifications.action.ts:19 |
verificationType | WalletVerificationType | The 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
Property | Type | Description | Defined in |
---|---|---|---|
challenge | Record <string , string > | The challenge parameters specific to the verification type. | sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:24 |
id | string | The unique identifier of the challenge. | sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:18 |
name | string | The name of the challenge. | sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:20 |
verificationType | WalletVerificationType | The type of verification required. | sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:22 |
WalletVerificationOptions
Defined in: sdk/viem/src/viem.ts:101
The options for the wallet client.
Properties
Property | Type | Description | Defined in |
---|---|---|---|
challengeResponse | string | The challenge response (used for HD wallets) | sdk/viem/src/viem.ts:109 |
verificationId? | string | The verification id (used for HD wallets), if not provided, the challenge response will be validated against all active verifications. | sdk/viem/src/viem.ts:105 |
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.
ClientOptions
ClientOptions =
Omit
<z.infer
<typeofClientOptionsSchema
>,"httpTransportConfig"
> &object
Defined in: sdk/viem/src/viem.ts:51
Type representing the validated client options.
Type declaration
Name | Type | Defined in |
---|---|---|
httpTransportConfig? | HttpTransportConfig | sdk/viem/src/viem.ts:52 |
CreateWalletVerificationChallengesResponse
CreateWalletVerificationChallengesResponse =
WalletVerificationChallenge
[]
Defined in: sdk/viem/src/custom-actions/create-wallet-verification-challenges.action.ts:30
Response from creating wallet verification challenges.
GetChainIdOptions
GetChainIdOptions =
Omit
<z.infer
<typeofGetChainIdOptionsSchema
>,"httpTransportConfig"
> &object
Defined in: sdk/viem/src/viem.ts:198
Type representing the validated get chain id options.
Type declaration
Name | Type | Defined in |
---|---|---|
httpTransportConfig? | HttpTransportConfig | sdk/viem/src/viem.ts:199 |
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.
Variables
ClientOptionsSchema
const
ClientOptionsSchema:ZodObject
<{accessToken
:ZodOptional
<ZodString
>;chainId
:ZodString
;chainName
:ZodString
;httpTransportConfig
:ZodOptional
<ZodAny
>;rpcUrl
:ZodUnion
<readonly [ZodString
,ZodString
]>; },$strip
>
Defined in: sdk/viem/src/viem.ts:25
Schema for the viem client options.
GetChainIdOptionsSchema
const
GetChainIdOptionsSchema:ZodObject
<{accessToken
:ZodOptional
<ZodString
>;httpTransportConfig
:ZodOptional
<ZodAny
>;rpcUrl
:ZodUnion
<readonly [ZodString
,ZodString
]>; },$strip
>
Defined in: sdk/viem/src/viem.ts:180
Schema for the viem client options.
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.