Skip to content

Instantly share code, notes, and snippets.

@akegaviar
Created August 17, 2020 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akegaviar/511b5122d5bd03b603ac915b057b1ea5 to your computer and use it in GitHub Desktop.
Save akegaviar/511b5122d5bd03b603ac915b057b1ea5 to your computer and use it in GitHub Desktop.
package com.helloBlock.contracts
import net.corda.core.contracts.*
import net.corda.core.contracts.Requirements.using
import net.corda.core.transactions.LedgerTransaction
import com.helloBlock.states.helloBlockState
// ************
// * Contract *
// ************
// Contract and state.
class helloBlockContract: Contract {
companion object {
// Used to identify our contract when building a transaction.
const val ID = "com.helloBlock.contracts.helloBlockContract"
}
// Contract code.
override fun verify(tx: LedgerTransaction) {
val command = tx.commands.requireSingleCommand<Commands.Send>()
val helloBlock = tx.outputsOfType<helloBlockState>().single()
"Sender must sign the message." using (helloBlock.origin.owningKey == command.signers.single())
}
// Used to indicate the transaction's intent.
interface Commands : CommandData {
class Send : Commands
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment