トップQs
タイムライン
チャット
視点
Solidity
ウィキペディアから
Remove ads
Solidityとは、ブロックチェーン上で実行されるスマート・コントラクトを記述するための手続き型プログラミング言語である。キャビン・ウッドによって作成された。JavaScriptやC++に似た構文を持つとされる[2]。SolidityによってコンパイルしたプログラムはEthereum Virtual Machine上での実行が想定されている[3]。
![]() | この記事は英語版の対応するページを翻訳することにより充実させることができます。(2022年1月) 翻訳前に重要な指示を読むには右にある[表示]をクリックしてください。
|
Remove ads
例
Solidityのプログラムの例は以下のようになっている[4]。
pragma solidity >= 0.7.0 <0.8.0;
contract Coin {
// The keyword "public" makes variables
// accessible from other contracts
address public minter;
mapping (address => uint) public balances;
// Events allow clients to react to specific
// contract changes you declare
event Sent (address from, address to, uint amount);
// Constructor code is only run when the contract
// is created
constructor() public {
minter = msg.sender;
}
// Sends an amount of newly created coins to an address
// Can only be called by the contract creator
function mint(address receiver, uint amount) public {
require(msg.sender == minter);
require(amount < 1e60);
balances[receiver] += amount;
}
// Sends an amount of existing coins
// from any caller to an address
function send(address receiver, uint amount) public {
require(amount <= balances[msg.sender], "Insufficient balance.");
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Sent (msg.sender, receiver, amount);
}
}
Remove ads
実行環境
Solodityを使えるウェブベース開発環境として、代表的に以下がある[5]。
- Remix IDE
- EthFiddle
Solidityが使えるブロックチェーンプラットフォームは、代表的には以下がある。
脚注
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads