Created
August 17, 2020 07:14
-
-
Save akegaviar/511b5122d5bd03b603ac915b057b1ea5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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