Skip to content

Instantly share code, notes, and snippets.

@arcticfloyd1984
Last active June 12, 2024 10:28
Show Gist options
  • Save arcticfloyd1984/c8e39cd8aa8c1fac6cb635587f132e89 to your computer and use it in GitHub Desktop.
Save arcticfloyd1984/c8e39cd8aa8c1fac6cb635587f132e89 to your computer and use it in GitHub Desktop.
return (async () => {
const relay = new GelatoRelay();
const account = privateKeyToAccount('0x215816ad5bfd524e13dc8b6b2ed2674d8f8973f403ad80909111dfe3757bc9d6');
const client = createWalletClient({
account,
transport: http(
'https://arb-sepolia.g.alchemy.com/v2/MVGOoAkMUxl6jrN3qLaSt7Z9dDB7iLUU', // RPC URL of the network where themint method is to be called
),
});
const publicClient = createPublicClient({
transport: http(
'https://opt-sepolia.g.alchemy.com/v2/hL0i6G6Rrp5GgKc_pa5JvezbgDLloVgz', // RPC URL of the network where the burn event is to be fetched
),
});
const { log } = context;
const { transactionHash } = log;
const receipt = await publicClient.getTransactionReceipt({
hash: transactionHash,
});
const { logs } = receipt;
let amount = BigInt(0);
for (const eventLog of logs) {
if (
eventLog.topics[0] ===
'0xcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5' // topic id of burn event
) {
const burnEvent = decodeEventLog({
abi: ERC_20_TOKEN_ABI,
topics: eventLog.topics,
data: eventLog.data,
});
const { args } = burnEvent;
amount = args.amount;
sender = args.sender;
}
}
//encode function data
const data = encodeFunctionData({
abi: ERC_20_TOKEN_ABI,
functionName: 'mint',
args: [sender, amount],
});
const relayRequest = {
user: account.address,
chainId: BigInt(421614),
target: '0xbaedb2a4eb22e05c01c677a4a9e973909599648b', // token address
data,
};
const response = await relay.sponsoredCallERC2771(
relayRequest,
client,
'Yzrtu5XgInRoLytEbSjWNkwnPpZbyssXTdIZBlty2zU_',
);
return response.taskId;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment