Keep data alive
Use the extend action so an entity is renewed shortly before it would expire.
Arkiv charges for the time data is stored, and an entity disappears when it expires. The extend
action renews an entity shortly before that happens.
await triggers.createRule({
name: 'Keep profile alive',
trigger: { on: 'expire', target: profileKey, offset: 43200n }, // 1 day early
action: 'extend',
extendDays: 30,
})When it fires, the worker sets the target's expiry to 30 days from that moment (it does not add
30 days to the old expiry). The receipt's result.newExpiresAt is the new expiry block.
The target must allow it
A worker can only extend an entity that was created with permissionless extension, or one it owns.
Create the entity with flags: { permissionlessExtension: true } if you want workers to keep it alive.
Otherwise the receipt records failed.
await wallet.createEntity({
payload, contentType: 'application/json', attributes,
expires: ExpirationTime.fromDays(30),
flags: { permissionlessExtension: true },
})A rule fires once. To keep something alive indefinitely, create the next rule after each extension, or extend from your own app on a schedule.
Permissionless extension lets anyone extend the entity. For data whose expiry is meaningful, such as a warrant canary, leave it off and extend from the owner's wallet. The Canary example does this.