Skip to content

Commit 9c1419f

Browse files
authored
Warning message to use DAppStaking v3 interface for precompile calls (#726)
* Warning message to use DAppStaking v3 interface for precompile calls * fix caution block
1 parent 201623a commit 9c1419f

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

docs/build/EVM/precompiles/index.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,41 @@ The Addresses can be checked in the [Astar repo](https://github.com/AstarNetwork
4444

4545
## Usage Example
4646

47-
Here we'll demonstrate how to interact with the dApp staking precompile using Remix IDE. Other precompiles can be accessed in a similar manner.
47+
This section demonstrates how to interact with the dApp Staking precompile from your contract or using Remix IDE. Other precompiles can be accessed in a similar manner.
48+
49+
### From contract
50+
51+
`DappsStakingV3.sol` contains functions that _mimic_ the interface of the latest version of `dApp Staking`. The interface can be found in the [Astar repository](https://github.com/AstarNetwork/Astar/blob/master/precompiles/dapp-staking/DappsStakingV3.sol).
52+
Developers are encouraged to use this interface to fully utilize dApp staking functionality.
4853

4954
```solidity
50-
import "./DappsStaking.sol";
55+
import "./DappsStakingV3.sol";
56+
5157
contract A {
52-
DappsStaking public constant DAPPS_STAKING = DappsStaking(0x0000000000000000000000000000000000005001);
58+
DAppStaking public constant DAPPS_STAKING = DAppStaking(0x0000000000000000000000000000000000005001);
5359
54-
/// @notice Check current era
55-
function checkCurrentEra() public view {
56-
uint256 currentEra = DAPPS_STAKING.read_current_era();
60+
/// @notice Check protocol state
61+
/// @return ProtocolState: The current protocol state.
62+
function checkProtocolState() public view returns (DAppStaking.ProtocolState memory) {
63+
DAppStaking.ProtocolState memory protocolState = DAPPS_STAKING.protocol_state();
64+
return protocolState;
5765
}
5866
}
5967
```
6068

69+
### Using Remix IDE
70+
71+
:::caution
72+
73+
The example below uses a soft-deprecated interface from the older dApp Staking v2.
74+
While it is still supported by the network, it does not reflect the recommended usage for dApp Staking v3.
75+
Please use the `v3` interface in a similar way for the latest version of the dApp Staking precompile.
76+
77+
:::
78+
6179
Example use: check `current era` and `total staked amount` in the `pallet-dapps-staking` for Shiden Network. For this example we will use Remix.
6280

63-
1. Copy `DappsStaking.sol` from [Astar repo](https://github.com/AstarNetwork/Astar/) and create new contract in Remix:
81+
1. Copy `DappsStakingV2.sol` from [Astar repo](https://github.com/AstarNetwork/Astar/blob/master/precompiles/dapp-staking/DappsStakingV2.sol) and create new contract in Remix:
6482

6583
![](https://i.imgur.com/mr0TcLq.png)
6684

0 commit comments

Comments
 (0)