# Solidityオンラインエディタ

### Solidity エディタ Remix.ethereum

Solidityは、ローカルでも開発できますがRemixという便利なオンラインIDEがあります。

[こちら](https://remix.ethereum.org/#optimize=true)でRemixに飛びます。

![](/files/-LPplZoR3Sj50rDAYIyo)

### 簡単なプログラムを書いてみる

すでにサンプルが書かれていますが、`pragma solidity ^0.4.0;`以外は消してしまって大丈夫です。早速簡単なプログラムを書いていきましょう。下記のcontract 部分を書いていきましょう。

```
pragma solidity ^0.4.0;
contract Inbox {
    string public message;
    function Inbox(string initialMessage) public{
        message = initialMessage;
    }
    
    function setMessage(string newMessage) public{
        message = newMessage;
    }
    
    function getMessage() public view returns(string){
        return message;
    }
}
```

上記のプログラムがかけたら、コンパイルしましょう。右上の「Complie」タブで「Start to complie」をクリックするとコンパイルが始まります。

![](/files/-LPpzXZutLtpQ9MdZTkf)

コンパイルができたら、コントラクト部分表示されます。

![](/files/-LPq-ePMWShr5XNTB7p3)

コンパイルが成功できたのを確認したら、右のタブの中で「Run」があるのでクリックします。その後、「Enviroment」のJavaScript VMを選択しましょう。これは、5つのアドレスと100etherが最初から付与されている仮想環境となります。

![](/files/-LPpyNCXLa-aX2iVKSJW)

![](/files/-LPq2FpAIrmNGqRaNlPY)

### コントラクトを確認する

「Run」の下に今回作成したInboxというコントラクトが表示されています。プログラムの内容とともに順次説明していきます。

まずは、初期設定としてmessageという文字列型の変数をInbox生成時に必要属性として設定します。

```
string public message;
function Inbox(string initialMessage) public{
        message = initialMessage;
    }
```

右にDeployと部分があるので、messageを作成してInboxを生成します。ダブルコーテーションで括って文字列にしてDeployボタンを押します。

![](/files/-LPq6azz2DZQMFoEBkQO)

すると、Deployed Contractsで生成された内容が確認できます。この際、アドレス内の100etherが若干減っていて、Contract生成に利用されていることがわかります。

![](/files/-LPq7DuoLTsN6uDeJGZz)

また、下部ではログが表示されていますのでそこでも確認できます。

![](/files/-LPq7FXG98dvPNlk_7i5)

setMessage(セッター)とgetMessage(ゲッター)をそれぞれ作成しています。setMessageでは、message変数を設定できます。getMessageでは、message変数を取得することができます。

```
function setMessage(string newMessage) public{
        message = newMessage;
    }
    
    function getMessage() public view returns(string){
        return message;
        
    }
```

Deployed Contractsでは、作成したInboxコントラクトのfunctionを試したり、内部の変数も表示されます。

![](/files/-LPq7ypEJKr4MRPwtEP2)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://24karamawariken.gitbook.io/ethereum-solidity/solidity-programming/solidityonrainedeta.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
