This contract uses Cosmwasm's provided architecture in conjunction with Provwasm to create a wasm smart contract that can be deployed to and interact with the Provenance Blockchain.
This contract provides functionality for creating a forward market contract for a single buyer and seller. A contract is instantiated by a buyer and then accepted by a seller. A buyer may allow any seller or mark the contract as private and only allow sellers of their choosing. The contract also requires a dealer, which is a party that will trigger the settlement of the contract once both parties have accepted the terms of the contract.
To instantiate a new instance of the contract, the following parameters are required:
use_private_sellers
: A flag indicating whether to limit the allowed seller addresses to the list defined in the allowed sellers listuse_private_buyers
: A flag indicating whether to limit the allowed buyer addresses to the list defined in the allowed buyers listallowed_sellers
: A list of addresses allowed to be a seller in the contract. This is only valid if the use_private_sellers field is set to true and must be empty when use_private_sellers is falseallowed_buyers
: A list of addresses allowed to be a buyer in the contract. This is only valid if the use_private_buyers field is set to true and must be empty when use_private_buyers is falsemax_buyer_count
: The maximum number of bids that can be placed on the contractdealers
: The list of addresses allowed to confirm and reset the contract
Example instantiation payload:
{
"use_private_sellers": true,
"use_private_buyers": true,
"allowed_sellers": ["mockpbselleraddress"],
"allowed_buyers": ["mockpbbuyeraddress"],
"max_buyer_count": 10,
"dealers": ["mockpbdealeraddress"]
}
Adds the sender as the seller on the contract. Along with the sender being added, a hash of the offer terms is added
offer_hash
: A hash generated from the offer terms that are stored in block vault
Example execution payload:
{
"AddSeller": {
"offer_hash": "b1c2d3e4"
}
}
offer_hash
: A hash generated from the offer terms that are stored in block vault
Example execution payload:
{
"UpdateSellerOfferHash": {
"offer_hash": "a1b2c3d4"
}
}
Allows the seller to finalize a list of specified pools. This means that the buyer can now review and potentially accept the pools
pool_denoms
: The list of denoms for the markers that hold the pooled assets
Example execution payload:
{
"FinalizePools": {
"pool_denoms": ["example.test.pool.0"]
}
}
Example execution payload:
{
"DealerConfirm": {}
}
allowed_sellers
: A list addresses allowed to be a seller in the contract. This is only valid if the is_private field is set to true and must be empty when is_private is false
Example execution payload:
{
"UpdateAllowedSellers": {
"allowed_sellers": ["mockpbselleraddress"]
}
}
Example execution payload:
{
"AcceptFinalizedPool": {}
}
Example execution payload:
{
"RescindFinalizedPools": {}
}
Example execution payload:
{
"ContractDisable": {}
}
bidder_address
: The address of the bidder for the bid the seller wishes to acceptagreement_terms_hash
: The hash of the terms that the seller is agreeing to that are stored in block vault
Example execution payload:
{
"bidder_address": "mockpbbidderaddress",
"agreement_terms_hash": "1d3d5d7"
}
agreement_terms_hash
: A hash generated from the agreement terms that are stored in block vault
Example execution payload:
{
"agreement_terms_hash": "2j547d5e"
}
Allows the admin of the contract to mint the tokens that will be given to the buyer when their bid is accepted
token_count
: The number of tokens that will be minted for the specified denomtoken_denom
: The denom of the marker that will hold the tokens
Example execution payload:
{
"token_count": "5000",
"token_denom": "test.mock.fake.denom"
}
The contract currently provides a single query route for getting its internal state. It can be queried with the following payload:
{
"GetContractState": {}
}
This assumes the user is running Mac OSX.
- To start developing with Rust, follow the standard guide.
- The contract uses
wasm-pack
with itsmake build
command. Use this installer command to install it. - To build the contract locally with its
make optimize
, a Docker Environment is also required.