Skip to main content
Rhinestone is compatible with ERC-4337. Some smart account modules, such as Social Recovery and legacy Smart Sessions, will require useroperations. This guide provides a quick overview of how to use ERC-4337 with the Rhinestone SDK.

Setup

You’ll first need to provide a bundler configuration:
const rhinestone = new RhinestoneSDK({
  apiKey: rhinestoneApiKey,
  bundler: {
    type: 'pimlico',
    apiKey: pimlicoApiKey,
  },
})
You can also provide a paymaster configuration to sponsor the gas:
const rhinestone = new RhinestoneSDK({
  apiKey: rhinestoneApiKey,
  paymaster: {
    type: 'pimlico',
    apiKey: pimlicoApiKey,
  },
})
See more on configuring the ERC-4337 infra in our guide.

Usage

To send a user operation:
const transactionResult = await rhinestoneAccount.sendTransaction({
  chain: base,
  calls: [
    {
      to: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
      value: 0n,
      data: '0xdeadbeef',
    },
  ],
})
const status = await rhinestoneAccount.waitForExecution(transactionResult)
You can also use the granular APIs to have more control over the flow:
const transactionData = await rhinestoneAccount.prepareUserOperation({
  chain: base,
  calls: [
    {
      to: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
      value: 0n,
      data: '0xdeadbeef',
    },
  ],
})
const signedData = await rhinestoneAccount.signUserOperation(transactionData)
const result = await rhinestoneAccount.submitUserOperation(signedData)
const status = await rhinestoneAccount.waitForExecution(result)