Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
"compile": "mimic compile",
"test": "mimic test",
"lint": "eslint .",
"trigger": "tsx scripts/create-trigger.ts"
"trigger": "tsx scripts/create-trigger.ts",
"prefill-url": "tsx scripts/get-trigger-prefill-url.ts"
},
"devDependencies": {
"@mimicprotocol/cli": "~1.0.0",
"@mimicprotocol/lib-ts": "~0.1.0",
"@mimicprotocol/sdk": "~0.1.0",
"@mimicprotocol/sdk": "~0.1.3",
"@mimicprotocol/test-ts": "~0.1.0",
"@types/chai": "^5.2.2",
"@types/mocha": "^10.0.10",
Expand Down
3 changes: 1 addition & 2 deletions scripts/env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Private key for signing transactions
# This should be the private key (without 0x prefix) used to authenticate with the Mimic SDK
# Private key for signing triggers
PRIVATE_KEY=your_private_key_here
39 changes: 39 additions & 0 deletions scripts/get-trigger-prefill-url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Chains, getTriggerPrefillUrl, TriggerType } from '@mimicprotocol/sdk'

// TODO: Replace with your deployed function's CID
const FUNCTION_CID = 'YOUR_FUNCTION_CID_HERE'

// TODO: Customize inputs to match your function's input structure
const inputs = {
chainId: Chains.Optimism,
token: '0x0b2c639c533813f4aa9d7837caf62653d097ff85', // USDC on Optimism
amount: '1',
recipient: '0x...',
maxFee: '0.1',
}

// TODO: Customize the trigger configuration
const config = {
type: TriggerType.Cron,
schedule: '0 2 * * *', // every day at 2am
delta: '2h',
endDate: Date.now() + 7 * 24 * 60 * 60 * 1000, // one week from now
}

async function main(): Promise<void> {
// TODO: Replace with your parameters
const prefillUrl = getTriggerPrefillUrl({
functionCid: FUNCTION_CID,
input: inputs,
config,
description: 'Example trigger description',
version: '1.0.1',
})

console.log(`Trigger prefill URL: ${prefillUrl}`)
}

main().catch((error) => {
console.error('Error getting trigger prefill URL:', error)
process.exit(1)
})