Created
March 20, 2025 18:30
-
-
Save recmo/3e8474b25ce40645933a6848986c7013 to your computer and use it in GitHub Desktop.
Safe transaction proposal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S deno run --allow-read --allow-env --allow-net | |
// Note: Deno is almost self-contained, but you need to create a deno.json file to make it work. | |
// This file should contain `{"nodeModulesDir": "none"}` | |
import { MetaTransactionData, OperationType } from 'npm:@safe-global/types-kit' | |
import SafeApiKit from 'npm:@safe-global/api-kit' | |
import Safe from 'npm:@safe-global/protocol-kit' | |
const chainId: bigint = 480n // World Chain | |
const provider = 'https://worldchain-mainnet.g.alchemy.com/public' | |
const safeAddress = '0x........................................' | |
const transactions: MetaTransactionData[] = [{ | |
to: '0x526643F69b81B008F46d95CD5ced5eC0edFFDaC6', // SafeMigration | |
value: '0', | |
data: '0x07f464a4', // migrateL2Singleton() | |
operation: OperationType.DelegateCall | |
}] | |
// Create transaction | |
const protocolKit = await Safe.init({ provider, safeAddress }) | |
const safeTransaction = await protocolKit.createTransaction({ transactions }) | |
const safeTxHash = await protocolKit.getTransactionHash(safeTransaction) | |
console.log("When the transaction is proposed, you can find it here:") | |
console.log(`https://app.safe.global/transactions/tx?safe=wc:${safeAddress}&id=multisig_${safeAddress}_${safeTxHash}`) | |
// Propose to Transaction Service | |
const apiKit = new SafeApiKit({ chainId }) | |
const safeInfo = await apiKit.getSafeInfo(safeAddress) | |
const result = await apiKit.proposeTransaction({ | |
safeAddress, | |
safeTxHash, | |
safeTransactionData: safeTransaction.data, | |
senderAddress: safeInfo.owners[0], | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment