/rif-scheduler-contracts

RIF Scheduler contracts POC

Primary LanguageJavaScript

logo

@rsksmart/rif-scheduler-contracts

npm docs ci Coverage Status
ci alerts

RIF Scheduler smart contracts are used to

  • purchase execution plans with ERC-20 tokens or RBTC,
  • schedule executions, (batch scheduling available)
  • check execution statuses and
  • cancel executions

The Service Provider must deploy this contract and set the address in the RIF Scheduler Service to start making revenue. The SP can:

  • Create plans and choose the payment currency. It can be RBTC. Plans have a price per execution, that is given by the window and the gas limit.
  • Execute the scheduled executions and collect the reward. It can also change the payee address.
  • Pause/unpause the contract. While paused, users can cancel purchasing.

Run for development

Install dependencies:

npm i

Run unit tests

npm test

Coverage report with:

npm run coverage

Run linter

npm run lint

Auto-fix:

npm run lint:fix

Static analysis

First install slither and run:

slither .

Branching model

  • main has latest release. Merge into main will deploy to npm. Do merge commits.
  • develop has latest approved PR. PRs need to pass ci and scan. Do squash & merge.
  • Use branches pointing to develop to add new PRs.
  • Do external PRs against latest commit in develop.

Deploy

First, create a .secret file with a mnemonic phrase. You will need to fund the account. Then run:

npm run deploy:ganache # deploy to :8545
npm run deploy:rsk-testnet # deploy to RSK Testnet
npm run deploy:rsk-mainnet # deploy to RSK Mainnet

Deployments

RIF is running an instance of the Scheduler.

RSK Testnet: 0xad249557515d8b89f2869834857bb872d7b5c398

RSK Mainnet: 0x7429d3222f7291a53b5fda3fe8d42b49d2ae6a19

Acknowledgments

Scheduled transaction times are not exact, they will be performed inside an execution window depending on the plan. The contract also uses block.timestamp to stablish if the scheduled transaction should be executed and/or refunded, which is subject to manipulation for short time periods.