Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
})
```
10 changes: 9 additions & 1 deletion src/SessionAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class SessionAccount {
provider,
session,
cacheAuthorisation = false,
paymasterRpc,
}: GetAccountWithSessionSignerParams) {
const sessionSigner = new SessionSigner(
(calls: Call[], invocationSignerDetails: InvocationsSignerDetails) => {
Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions src/SessionAccount.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Call,
InvocationsSignerDetails,
ProviderInterface,
PaymasterRpc,
} from "starknet"
import { Session } from "./session.types"
import { Network } from "./outsideExecution.types"
Expand All @@ -11,6 +12,7 @@ export interface GetAccountWithSessionSignerParams {
provider: ProviderInterface
session: Session
cacheAuthorisation?: boolean
paymasterRpc?: PaymasterRpc
}

export interface GetSessionSignatureForTransactionParams {
Expand Down
2 changes: 2 additions & 0 deletions src/session.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
BigNumberish,
CairoCustomEnum,
Calldata,
PaymasterRpc,
ProviderInterface,
Signature,
constants,
Expand Down Expand Up @@ -78,6 +79,7 @@ export type BuildSessionAccountParams = {
provider: ProviderInterface
useCacheAuthorisation?: boolean
argentSessionServiceBaseUrl?: string
paymasterRpc?: PaymasterRpc
}

export type ArgentServiceSignatureResponse = {
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const buildSessionAccount = async ({
provider,
argentSessionServiceBaseUrl,
useCacheAuthorisation,
paymasterRpc,
}: BuildSessionAccountParams): Promise<Account> => {
const dappService = new SessionAccount(
session,
Expand All @@ -118,6 +119,7 @@ const buildSessionAccount = async ({
provider,
session,
cacheAuthorisation: useCacheAuthorisation,
paymasterRpc,
})
}

Expand Down