StorageMinerActor
is a built-in actor that handles storage mining operations and the collection of proofs..car
format..car
; use the following command to clone the submodule as well:
.env.example
file, delete its content and paste the following:
.env
.
.env
file.
.car
format. Prior to proposing a deal, these files need to be converted, and certain necessary information must be obtained. The most straightforward method to accomplish this is by utilizing the FVM Data Depot page, which we will explore in this tutorial. Alternatively, you can use the included submodule in the repository to generate .car
files. Instructions for this process can be found within the repository.
Login into the FVM Data Depot page and click Upload New File. Once the process is done, you can access the page with the information we’ll need. To propose a deal, we will need the following:
hardhat.config.js
contracts
directory. You will be deploying the DealClient.sol
smart contract.
Here is a high-level overview of the contract:
@zondax/filecoin-solidity
package. It also defines several structs to model deal requests and extra parameters associated with these requests.DealClient
, is designed to facilitate the creation and management of storage deals on the Filecoin network. It includes several mappings to keep track of deal requests, piece requests, piece providers, piece deals, and piece statuses.makeDealProposal
function allows the contract owner to create a new deal proposal. The proposal is stored in the dealRequests
array, and various mappings are updated to track the new proposal.getDealProposal
function allows anyone to retrieve a deal proposal given its ID. It returns a CBOR-encoded representation of the proposal.authenticateMessage
and dealNotify
functions are designed to be called by the Filecoin market actor as part of the deal publishing process. They validate the deal proposal and update the contract’s state to reflect the published deal.updateActivationStatus
function can be called to retrieve the activation status of a deal and update the contract’s state accordingly.addBalance
and withdrawBalance
functions allow the contract owner to add funds to the storage market actor’s escrow and withdraw funds from it.receiveDataCap
function is designed to be called by the Filecoin datacap actor. It emits an event to signal that datacap has been received.handle_filecoin_method
function is a universal entry point for calls coming from built-in Filecoin actors. It dispatches these calls to the appropriate function based on the method number.0_deploy.js
script in the deploy
directory. This is a standard Hardhat deploying script, and it will work to deploy your contract. If you want to also convert the new contract address to f4address to find it in the explorer, as it does not support Ethereum addresses, delete the code from the deploy file and paste the following:
DealClient
smart contract:
makeDealProposal
function from the smart contract, it’s important to understand how the payload is constructed and the various parameters involved. To this end, you’ll find a struct named DealRequest
that outlines these parameters.
The DealRequest
struct looks like this:
piece_cid
— a unique identifier of the piece obtained when converting the file to .car
.
piece_size
— represents the size of the piece in bytes.
verified_deal
— indicates whether the deal has been allocated DataCap
or not. DataCap
boosts the “quality-adjusted power” of storage providers by a factor of 10, resulting in better block rewards. Notaries receive batches of DataCap
that they can distribute to clients. DataCap
is consumed when used for making storage deals.
label
— refers to the DataCID
obtained during the conversion of the file to .car
.
start_epoch
— represents the epoch at which you want the storage to begin.
end_epoch
— signifies the epoch at which you want the storage to conclude.
storage_price_per_epoch
— the price offered per epoch in attoFil
, similar to wei in Ethereum. This price corresponds to the cost per gigabyte of storage every 30 seconds (one epoch). A value of 1000000000000000000
means the deal offers 1 FIL per gigabyte stored every 30 seconds. The price can be set to zero, indicating it is free.
provider_collateral
— the collateral that the storage provider must provide for the deal. It can be set to zero.
client_collateral
— the collateral that you, as the client, must provide for the deal. It can also be set to zero.
extra_params_version
— generally set to 1.
ExtraParamsV1
— includes additional parameters:
car_link
— the link to the .car
file obtained during the conversion.car_size
— the size of the .car
file obtained during the conversion.skip_ipni_announcement
— indicates whether the deal should be announced to IPNI indexers or not.remove_unsealed_copy
— specifies whether the storage provider should remove an unsealed copy..car
.
This will return a message with your proposal ID: