체인의정석

solidity 5.0 => 6.0 버전업 문법 변화 주의사항 본문

블록체인/퍼블릭 블록체인

solidity 5.0 => 6.0 버전업 문법 변화 주의사항

체인의정석 2021. 2. 8. 09:59
728x90
반응형

1. abstarct =>  컨트렉트에 있는 함수 중에 전부 또는 하나라도 { } 와 같이 내용이 없고 정의가 안 되어 있는 경우 abstarct를 써주어야 한다.

 

인터페이스와의 차이는? : 인터페이스는 함수의 내용이 있으면 안되고 상속을 받으면 안되며, 모든 함수는 external로 가시성을 설정해 주어야 한다.

 

또한 생성자를 선언할 수 없으며, 상태변수도 선언하면 안된다.

 

docs.soliditylang.org/en/v0.6.6/contracts.html?highlight=contract%20abstract#abstract-contracts

 

Contracts — Solidity 0.6.6 documentation

State variables can be declared as constant or immutable. In both cases, the variables cannot be modified after the contract has been constructed. For constant variables, the value has to be fixed at compile-time, while for immutable, it can still be assig

docs.soliditylang.org

2.  virtual => 이후에 override될 수 있는 함수에 미리 선언 abstract 로 선언된 컨트렉트에서 내용이 없는 함수는 주로 오버라이딩이 되는 함수이기 때문에 이때 주로 쓰인다. 

728x90
반응형
Comments