The smart contract in Forge is a mechanism for user-defined transaction processing layer logic. Forge CLI provides multiple Subcommands for managing smart contracts on the chainIf a developer develops his own smart contract and wants to share it with others, he can publish it as a smart contract blocklet.

The main contents of the smart contract blocklet include:

  • The source code of the contract itself
  • Example of contract call

We we just published a very simple Smart contract

Specific use method:

cd /tmp
forge blocklet:use contract-product-factory

Wait for the Forge CLI to install the contract code, then:

❯ tree ./protocol
./protocol
├── config.yml
└── protocol.proto

0 directories, 2 files

After that forge contract:compileAnd then forge contract:deploy, And then you can use this contract in the code. For an example code using this contract, see Forge JavaScript SDK