massalabs/massa

[Meta] ChainId

sydhds opened this issue · 3 comments

sydhds commented

Intro

ChainId implementation for Massa

Documentation

ChainId idea comes from Etherum (and was required to separate the network between Ethereum & Ethereum Classic)

Ethereum ChainId

Example code from Umbrella:

function update(
    bytes32[] calldata _priceKeys,
    PriceData[] calldata _priceDatas,
    Signature[] calldata _signatures
) external {
    if (_priceKeys.length != _priceDatas.length) revert ArraysDataDoNotMatch();

    bytes32 priceDataHash = keccak256(abi.encode(getChainId(), address(this), _priceKeys, _priceDatas));
    verifySignatures(priceDataHash, _signatures);

    ...
}

function getChainId() public view returns (uint256 id) {
    // solhint-disable-next-line no-inline-assembly
    assembly {
        id := chainid()
    }
}

Implementation

Remaining questions

damip commented
sydhds commented
sydhds commented
  • PR to chain id list site