Package Exports
- @settlemint/sdk-portal
- @settlemint/sdk-portal/package.json
Readme
SettleMint SDK
✨ https://settlemint.com ✨
Integrate SettleMint into your application with ease.
Table of Contents
About
The SettleMint Smart Contract Portal SDK provides a seamless way to interact with the Smart Contract Portal Middleware API. It enables you to easily interact with your smart contracts using a REST or GraphQL API.
The SDK offers a type-safe interface for all Portal API operations, with comprehensive error handling and validation. It integrates smoothly with modern TypeScript applications while providing a simple and intuitive developer experience.
For detailed information about using the Smart Contract Portal Middleware, check out our official documentation.
API Reference
Functions
createPortalClient()
createPortalClient<
Setup
>(options
,clientOptions?
):object
Defined in: sdk/portal/src/portal.ts:61
Creates a Portal GraphQL client with the provided configuration.
Type Parameters
Type Parameter |
---|
Setup extends AbstractSetupSchema |
Parameters
Parameter | Type | Description |
---|---|---|
options |
{ accessToken : string ; cache : "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" ; instance : string ; } |
Configuration options for the Portal client |
options.accessToken |
string |
- |
options.cache? |
"default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" |
- |
options.instance? |
string |
- |
clientOptions? |
RequestConfig |
Additional GraphQL client configuration options |
Returns
object
An object containing the configured GraphQL client and graphql helper function
Name | Type | Defined in |
---|---|---|
client |
GraphQLClient |
sdk/portal/src/portal.ts:65 |
graphql |
initGraphQLTada <Setup > |
sdk/portal/src/portal.ts:66 |
Throws
If the provided options fail validation
Example
import { createPortalClient } from '@settlemint/sdk-portal';
import type { introspection } from "@schemas/portal-env";
export const { client: portalClient, graphql: portalGraphql } = createPortalClient<{
introspection: introspection;
disableMasking: true;
scalars: {
// Change unknown to the type you are using to store metadata
JSON: unknown;
};
}>({
instance: process.env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT,
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
});
// Making GraphQL queries
const query = graphql(`
query GetPendingTransactions {
getPendingTransactions {
count
}
}
`);
const result = await client.request(query);
Type Aliases
ClientOptions
ClientOptions =
z.infer
<*typeof*ClientOptionsSchema
>
Defined in: sdk/portal/src/portal.ts:24
Type representing the validated client options.
RequestConfig
RequestConfig =
ConstructorParameters
<*typeof*GraphQLClient
>[1
]
Defined in: sdk/portal/src/portal.ts:10
Configuration options for the GraphQL client, excluding 'url' and 'exchanges'.
Variables
ClientOptionsSchema
const
ClientOptionsSchema:ZodObject
<{accessToken
:ZodString
;cache
:ZodOptional
<ZodEnum
<["default"
,"force-cache"
,"no-cache"
,"no-store"
,"only-if-cached"
,"reload"
]>>;instance
:ZodUnion
<[ZodString
,ZodString
]>; },"strip"
,ZodTypeAny
, {accessToken
:string
;cache
:"default"
|"force-cache"
|"no-cache"
|"no-store"
|"only-if-cached"
|"reload"
;instance
:string
; }, {accessToken
:string
;cache
:"default"
|"force-cache"
|"no-cache"
|"no-store"
|"only-if-cached"
|"reload"
;instance
:string
; }>
Defined in: sdk/portal/src/portal.ts:15
Schema for validating Portal client configuration 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.