diff --git a/package.json b/package.json index 5fc084f..bdd60e1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/env.template b/scripts/env.template index 15d793f..1302ffa 100644 --- a/scripts/env.template +++ b/scripts/env.template @@ -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 diff --git a/scripts/get-trigger-prefill-url.ts b/scripts/get-trigger-prefill-url.ts new file mode 100644 index 0000000..64b9599 --- /dev/null +++ b/scripts/get-trigger-prefill-url.ts @@ -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 { + // 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) +})