contract A {
B b;
function A(address _b) public {
b = B(_b);
}참고
- https://ethereum.stackexchange.com/questions/5992/how-much-computation-can-be-done-in-a-fallback-function
- https://bitcoin.stackexchange.com/questions/39132/what-is-gas-limit-in-ethereum
sending a transaction costs 21000 gas
A recipient contract's fallback function only gets a 2300 gas stipend if it was invoked with recipient.transfer or recipient.send
fallback 함수가 호출되는 여러 경우가 있는데 그 중 receiver.send 함수 또는 receiver.transfer 함수로 인해 receiver의 fallback 함수가 호출된다. 이 때 fallback 함수 호출과 함께 2300gas를 봉급으로 주어지게 된다.
This is the same as an external account paying recipient with web3.eth.sendTransaction({to:recipient, gas:21000, ...}).
pragma solidity^0.4.12;
contract Test {
function test(uint[20] a) public returns (uint){
return a[10]*2;
}smart contract security를 improve해주는 전략과 이 전략을 따르지 않았을 때 문제가 발생할 수 있는 코드를 함께 제시한다. 또한 smart contract를 protect할 수 있는 방법에 대한 코드도 함께 제시한다.
- code가 silently하게 fail하는 것을 피해야 한다. 또한 unstable하거나 inconsistent한 state로 실행이 계속되는 것을 피해야 한다.
- library를 사용하면 modular, reusable elegant한 contract를 짤 수 있다.
- standard library가 아직 개발되지 않았다.
- deployed contract는 업그레이드할 수 없다.
- EVM 외부에서 data를 가져올 수 없다. 이는 Oracle을 포함하는 트랜잭션을 날려야만 가능하다.
- library는 contract와는 다른 type이다.
NewerOlder