tip: 174
title: CHAINID instructions in TVM
author: taihao.fu@gmail.com
status: Final
type: Standards Track
category : VM
created: 2020-08-12
Simple Summary
To provide CHAINID instruction in TVM.
Abstract
This is value can be read from smart contract to distinguish current chain with other chains.
Motivation
Currently we have multiple chains in TRON ecosystem those are build from 3 main ways: testnets, side-chain and cross-chains.From smart contract perspective, currently we don't have a mechnism to distinguish those chains, which leads to potential replay attacks. As a result, a chainid parameter is required in TVM level to guanrantee smart contract safety.
Specification
0x46
: CHAINID
CHAINID
takes 0 operands pop up from stack.
The return value is the genesis block id for this chain as uint256.
Rationale
CHAINID
tier.ExtTier
20 Energy