Start

Publish your first hook

Publishing a hook makes one instruction of your program callable from every private balance in Pook. You describe the instruction once. Your program does not change, nothing is deployed, and nobody has to approve it. From then on, every run through the hook pays you a share of its fee.

This page gets a first hook published. It takes about ten minutes with your program's IDL at hand.

What a hook needs from your program

Pick one instruction that takes an asset from a user and gives one back: a swap, a deposit, a stake. For that instruction you need to know three things.

  • Which argument is the amount. Pook fills it with the amount the holder proved.
  • Which account signs as the user, and which token accounts pay and receive. Pook's stage stands in for all three.
  • Which other accounts are always the same, and which depend on the asset or the market. The first are written into the hook. The second are named by each run.

That is what a slot is: a place in the instruction that a run fills. Everything that is not a slot is fixed for good when you publish.

Publish it

  1. Read the IDL

    Open Publish, paste your program ID or its IDL as JSON, and press Read the IDL.

  2. Choose the instruction

    Pick the one instruction the hook will call.

  3. Mark the slots

    Give the amount argument the role Amount in. Give the account that signs as the user the role Stage authority, the account that pays Stage in and the account that receives Stage out. Mark accounts that vary from run to run as Caller supplies. Leave the rest fixed.

  4. Name it

    Give the hook a Name in the form protocol.action, a Label, and one sentence on what goes in and what comes back.

  5. Simulate

    Type a sample amount and press Simulate. The builder runs the instruction against the chain with the stage in place and shows the program's logs. Fix what it reports until it reads Simulation passed.

  6. Publish

    Connect the wallet that will be the author and press Publish. Approve the one transaction. When it lands, the hook is in the registry.

What you have now

  • A hook account on chain. Its address is derived from the name, it names your wallet as author, and it cannot be edited or removed.
  • A page in the registry, at /hooks/ followed by the name, with the hook's record, its runs and its volume.
  • A run screen anyone with a private balance can use, and one line for any app: pook.run('yourname.supply', { ... }).
  • An author's share of the run fee of every run through it, collected for you by the program and claimed whenever you like.

Where to go from here