본문 바로가기
Company

Remix Ethereum

by hasd 2025. 3. 24.

이더리운 원리 실습해보기

https://remix.ethereum.org/

 

Remix - Ethereum IDE

 

remix.ethereum.org

pragma solidity >=0.4.0 <0.5.0;

contract first_contract {

    uint public balance;
    address[] private givers;
    address private taker;
    address public owner;

    modifier onlyOwner() { require (msg.sender == owner); _;}

    constructor() public payable {
        owner = msg.sender;
    }

    function setTaker(address _addr) onlyOwner public {
        taker = _addr;
    }

    function deposit() public payable {
        balance += msg.value;
        givers.push(msg.sender);
    }

    function sendMoney() onlyOwner public payable {
        require (givers.length >= 2);
        taker.transfer(balance);
    }
}

 

댓글