Skip to content

Commit

Permalink
Add a stake rights splitting script
Browse files Browse the repository at this point in the history
Adds a small POC validator that separates the owner of a stake address (who receives rewards and can reclaim the deposit) and the delegator (who *only* controls the delegation capabilities. This could be used for a cold/hot wallet setup, for example
  • Loading branch information
Quantumplation committed Jul 18, 2024
1 parent 497e4dd commit c39de16
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions validators/stakerights.ak
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use aiken/list
use aiken/transaction.{ScriptContext, WithdrawFrom, Publish}
use aiken/transaction/certificate.{CredentialRegistration, CredentialDeregistration, CredentialDelegation}

validator(owner: ByteArray, delegator: ByteArray) {
fn stake(_r: Data, ctx: ScriptContext) -> Bool {
when ctx.purpose is {
WithdrawFrom(_) -> {
list.has(ctx.transaction.extra_signatories, owner)
}
Publish(cert) -> {
when cert is {
CredentialRegistration(_) | CredentialDeregistration(_) -> {
list.has(ctx.transaction.extra_signatories, owner)
}
CredentialDelegation(_, _) -> {
list.has(ctx.transaction.extra_signatories, delegator)
}
_ -> False
}
}
_ -> False
}
}
}

0 comments on commit c39de16

Please sign in to comment.