diff --git a/README.md b/README.md index 29ab357..5a490f0 100644 --- a/README.md +++ b/README.md @@ -203,12 +203,13 @@ const sessionAccount = await buildSessionAccount({ session, sessionKey, provider: new RpcProvider({ - nodeUrl: "https://starknet-sepolia.public.blastapi.io/rpc/v0_7", + nodeUrl: "https://starknet-sepolia.public.blastapi.io/rpc/v0_8", chainId: constants.StarknetChainId.SN_SEPOLIA }), argentSessionServiceBaseUrl: ARGENT_SESSION_SERVICE_BASE_URL // Optional: defaulted to mainnet url }) + // example for creating the calldata const erc20Contract = new Contract( Erc20Abi as Abi, @@ -239,3 +240,27 @@ const { signature, outsideExecutionTypedData } = network // values "mainnet" | "sepolia", default to "mainnet" }) ``` + +## Creating a session account with paymaster + +[starknetjs paymaster documentation](https://starknetjs.com/docs/guides/paymaster/#overview) + +```typescript + +const paymasterRpc = new PaymasterRpc({ + nodeUrl: "node-url, + headers: { "api-key": "your-api-key- }, +}) + +const sessionAccount = await buildSessionAccount({ + useCacheAuthorisation: false, // optional and defaulted to false, will be added in future developments + session, + sessionKey, + provider: new RpcProvider({ + nodeUrl: "https://starknet-sepolia.public.blastapi.io/rpc/v0_8", + chainId: constants.StarknetChainId.SN_SEPOLIA + }), + argentSessionServiceBaseUrl: ARGENT_SESSION_SERVICE_BASE_URL, // Optional: defaulted to mainnet url + paymasterRpc +}) +``` diff --git a/src/SessionAccount.ts b/src/SessionAccount.ts index 2c0a00a..5da8907 100644 --- a/src/SessionAccount.ts +++ b/src/SessionAccount.ts @@ -62,6 +62,7 @@ export class SessionAccount { provider, session, cacheAuthorisation = false, + paymasterRpc, }: GetAccountWithSessionSignerParams) { const sessionSigner = new SessionSigner( (calls: Call[], invocationSignerDetails: InvocationsSignerDetails) => { @@ -75,7 +76,14 @@ export class SessionAccount { }, ) - return new Account(provider, session.address, sessionSigner) + return new Account( + provider, + session.address, + sessionSigner, + undefined, + undefined, + paymasterRpc, + ) } private async signTransaction( diff --git a/src/SessionAccount.types.ts b/src/SessionAccount.types.ts index 3acd201..716521e 100644 --- a/src/SessionAccount.types.ts +++ b/src/SessionAccount.types.ts @@ -3,6 +3,7 @@ import { Call, InvocationsSignerDetails, ProviderInterface, + PaymasterRpc, } from "starknet" import { Session } from "./session.types" import { Network } from "./outsideExecution.types" @@ -11,6 +12,7 @@ export interface GetAccountWithSessionSignerParams { provider: ProviderInterface session: Session cacheAuthorisation?: boolean + paymasterRpc?: PaymasterRpc } export interface GetSessionSignatureForTransactionParams { diff --git a/src/session.types.ts b/src/session.types.ts index 0afab2c..5d9ba7a 100644 --- a/src/session.types.ts +++ b/src/session.types.ts @@ -3,6 +3,7 @@ import { BigNumberish, CairoCustomEnum, Calldata, + PaymasterRpc, ProviderInterface, Signature, constants, @@ -78,6 +79,7 @@ export type BuildSessionAccountParams = { provider: ProviderInterface useCacheAuthorisation?: boolean argentSessionServiceBaseUrl?: string + paymasterRpc?: PaymasterRpc } export type ArgentServiceSignatureResponse = { diff --git a/src/utils.ts b/src/utils.ts index da29ace..defa67c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -107,6 +107,7 @@ const buildSessionAccount = async ({ provider, argentSessionServiceBaseUrl, useCacheAuthorisation, + paymasterRpc, }: BuildSessionAccountParams): Promise => { const dappService = new SessionAccount( session, @@ -118,6 +119,7 @@ const buildSessionAccount = async ({ provider, session, cacheAuthorisation: useCacheAuthorisation, + paymasterRpc, }) }