Build · 2 of 4
Your first covenant
This is SimpleCovenant, verbatim from the official
Silverscript tutorial.
Twelve lines that already do something real: coins locked by it can only ever be
sent to one predetermined recipient.
pragma silverscript ^0.1.0;
contract SimpleCovenant(pubkey recipient) {
entry spend() {
byte[36] recipientScriptPubKey = new ScriptPubKeyP2PK(recipient);
require(tx.outputs[0].scriptPubKey == byte[](recipientScriptPubKey));
}
} What each piece does
contract SimpleCovenant(pubkey recipient)— the constructor argument bakes the recipient into the covenant Covenant A lock on coins that dictates how they are allowed to move next. Not a promise or a bookkeeper's note: consensus rejects any spend that breaks the rule. when it's created. It can never change.entry spend()— the one entry Entry A callable function on a contract or actor — the only doors into it. Anything an entry doesn't allow can't happen. : the only way these coins move.tx.outputs[0].scriptPubKey— transaction introspection: the contract examines the spending transaction itself.require(…)— the rule. If output 0 doesn't pay the baked-in recipient, consensus rejects the whole transaction. There is no appeal.
Compile it
Save the contract as simple.sil in your Silverscript checkout, then:
cargo run -p silverscript-lang --bin silverc -- simple.sil -o artifact.json
The artifact is your compiled covenant. Constructor arguments are supplied as JSON —
for example [{ "kind": "int", "value": 100 }] for an integer parameter.
Step through it
The repo ships a CLI debugger that runs entries against arguments so you can watch a rule pass or fail:
cargo run -p cli-debugger -- silverscript-lang/tests/examples/if_statement.sil \
--function hello --ctor-arg 3 --ctor-arg 10 --arg 1 --arg 2 Point it at your own simple.sil and an entry once you've compiled it.
Getting it on-chain
Deployment means funding an address whose script is your compiled covenant, then spending it with a witness Witness The data supplied when spending — signatures, arguments, revealed scripts — that satisfies (or fails) the lock on the coins. that satisfies the entry — on testnet-10 first, always. The official tutorial focuses on the language rather than deployment tooling (checked 2026-09-10), so the practical paths today are the kascov.io playground and the patterns in the KCC20 book. A full deploy-and-spend walkthrough lands here as the tooling settles.