Describe for AA
If you're running an ERC-4337 account abstraction wallet, we have a separate endpoint that works like Describe, but takes an userOp object instead.
Let's see an example of how to call Describe4337:
const axios = require('axios');
const API_BASE_URL = 'https://foresight.noves.fi';
// Set your API Key as an env var or directly as a string
const NOVES_API_KEY = process.env.NOVES_API_KEY;
async function describeUserOp(chain, userOp) {
try {
const response = await axios.post(
`${API_BASE_URL}/evm/${chain}/describe4337`,
{ userOp: userOp },
{
headers: {
apiKey: NOVES_API_KEY,
},
}
);
return response.data;
} catch (error) {
console.error('Error describing user operation:', error);
return null;
}
}
const chain = 'arbitrum';
// Sample userOp object
const userOp = {
sender: '0x0aEdF24801868f1636a078d12DF52061049E86Cb',
nonce: 10,
initCode: '0x',
callData:
'0x70641a220000000000000000000000005845696f6031bfd57b32e6ce2ddea19a486fa5e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044441a3e700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
callGasLimit: 1025072,
verificationGasLimit: 90297,
preVerificationGas: 1567969,
maxFeePerGas: 130000000,
maxPriorityFeePerGas: 130000000,
signature:
'0x000000000000000000000000000000000000000000000000000000000064d8f8cccc8e6e4ee8dec06dbc2172c131148bd322993ebbd45eb69c82964d220008ebad04071f667e28e39aa1bfdca7d3144c623cb52f93d077f54dd4e0b3713b48818a1b',
paymasterAndData:
'0xd4ca5b29f8e222aaeef944f445d1ac368a5d76940000000000000000000000000000000000000000000000000000000064d8fe6d0096351224cad797a4923056128a39882981452d5477c977ff1a90a9df08fec35ddd842f69ea02f5b1a3f3c024986eb549db570f56cef35d7749c43590b0f6a61b',
};
describeUserOp(chain, userOp).then((data) => {
console.log(JSON.stringify(data, null, 2));
});
This will return a type and description:
{
"description": "Unstake assets.",
"type": "unstakeToken"
}
Similar to the "regular" Describe endpoint we saw in the previous page, this endpoint is lightweight and will simply return a type and description of what is about to happen.
Both the type and description are returned from the perspective of the userOp sender.
In your wallet, you can then print the description in a component. For example saying:
"This transaction will unstake assets"
Updated about 1 year ago