TypeError: parameters.transport is not a function
Closed this issue · 8 comments
I'm trying to replicate a demo example that is shown on the Pimlico dashboard (https://dashboard.pimlico.io/onboarding), but it running node index.js
reverts with an error.
Here is my package.json
:
{
"name": "pimlico",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"type": "module",
"author": "",
"license": "ISC",
"dependencies": {
"permissionless": "^0.1.4",
"viem": "^2.7.19"
}
}
Here is my main.js
(basically the same code as shown in the demo, but in Javascript instead of Typescript):
import { createSmartAccountClient } from "permissionless";
import { privateKeyToSimpleSmartAccount } from "permissionless/accounts";
import { http } from "viem";
import { sepolia } from "viem/chains";
import { bundlerClient, paymasterClient, publicClient } from "./clients.js";
(async function () {
const account = await privateKeyToSimpleSmartAccount(publicClient, {
privateKey:
"0x36e512afe490fed9b9e89e3be886640083050dee973d6c913511870ee2a51cc9",
factoryAddress: "0x9406Cc6185a346906296840746125a0E44976454", // simple account factory
entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", // global entrypoint
});
const smartAccountClient = createSmartAccountClient({
account,
chain: sepolia,
transport: http(
"https://api.pimlico.io/v1/mumbai/rpc?apikey=21...12", // API key truncated for privacy, it's actually a valid value
),
sponsorUserOperation: paymasterClient.sponsorUserOperation,
});
const gasPrices = await bundlerClient.getUserOperationGasPrice()
const txHash = await smartAccountClient.sendTransaction({
to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
value: 0n,
data: "0x1234",
maxFeePerGas: gasPrices.fast.maxFeePerGas,
maxPriorityFeePerGas: gasPrices.fast.maxPriorityFeePerGas,
});
})();
And here is clients.js
:
import { createPimlicoBundlerClient, createPimlicoPaymasterClient } from "permissionless/clients/pimlico";
import { createPublicClient, http } from "viem";
export const publicClient = createPublicClient({
transport: http("https://rpc.ankr.com/polygon_mumbai"),
});
export const bundlerClient = createPimlicoBundlerClient({
transport: http(
"https://api.pimlico.io/v1/mumbai/rpc?apikey=21....12", // API key truncated for privacy, it's actually a valid value
),
});
export const paymasterClient = createPimlicoPaymasterClient({
transport: http(
"https://api.pimlico.io/v2/mumbai/rpc?apikey=21....12", // API key truncated for privacy, it's actually a valid value
),
});
The error I've been getting is the following:
node_modules/viem/_esm/clients/createClient.js:9
const { config, request, value } = parameters.transport({
^TypeError: parameters.transport is not a function
I get an error running node index.js
Please suggest me what to do. :)
Any wizard here who was able to figure out how to solve that bug? 🙂
experiencing something similar myself!
Can you share the repro?
Hey can you share a reproducible repo?
Yes, I can: https://github.com/milaabl/pimlico-repro. @pavlovdog @plusminushalf Thanks in advance!!
Run node index.js
.
@milaabl awesome, thank you for the repro! Changing transport
to bundlerTransport
helps!
const smartAccountClient = createSmartAccountClient({
account,
chain: sepolia,
bundlerTransport: http(
"https://api.pimlico.io/v1/mumbai/rpc?apikey=....",
),
sponsorUserOperation: paymasterClient.sponsorUserOperation,
});
Also, we don't support Polygon Mumbai since it's already deprecated. Feel free to use any other testnet.
@pavlovdog thank you! Indeed!