Integration Example: Auto-Staking Workflow
Last updated
Was this helpful?
Last updated
Was this helpful?
The figure below demonstrates a typical workflow of how onâchain rewards from a thirdâparty âRewards Dappâ can be automatically reâstaked into a separate âStaking Dappâ via an offâchain âAutoâstaking Serviceâ and an MBA wallet module.
The auto-staking process consists of the following five steps:
Step 1: Rewards Distribution â MBA The thirdâparty Rewards Dapp issues a token transfer to the MBA address (0x1234) by calling transfer(address recipient, uint256 amount)
on the token contract. Those tokens land in the MBAâs onâchain account.
Step 2: Event Monitoring by Offâchain Indexer The Autoâstaking Serviceâs offâchain indexer watches the blockchain for the Transfer
event to the userâs MBA address. As soon as it sees a new reward deposit, it triggers the next step.
Step3: Indexer â Autoâstaking Contract Invocation The indexer sends an onâchain transaction invoking the Autoâstaking Serviceâs smart contract, passing in the recipient address (0x1234) so that the service can act on behalf of that user.
Step 4: Autoâstaking Contract â MBA DelegateCall The Autoâstaking Contract uses Solidityâs call
to execute a payload {stake(uint256 amount)}
in the context of the MBA. This means the MBA itself is authorizing the staking action, preserving the userâs onâdevice key/security assumptions.
Step 5: MBA â Thirdâparty Staking Dapp Finally, the âŻMBA makes a standard stake(uint256 amount)
call to the thirdâparty Staking Dappâs contract (staking service can be provided by other projects), locking the newly received reward tokens into the staking program.