首页 > 区块链 > 以太坊虚拟机(EVM)runtime环境

以太坊虚拟机(EVM)runtime环境

2019-10-11 12:00:35|浏览量:276|

以太坊虚拟机(EVM)runtime环境

EVM(以太坊虚拟机)在以太坊区块链上提供了操作系统运行时环境。智能合约中的实体代码必须经历从高级人类可读代码到低级机器可读代码的转换。这需要将文本转换为十六进制值,从而将代码转换为bytecode。bytecode由编译器生成。然后,字节码由EVM处理并在网络上执行。EVM可以构建在FPGA(现场可编程阵列)或基于堆栈的CPU之上。它提供了一个抽象层,允许代码跨分布式平台(例如以太坊网络)进行可移植性。

EVM是所谓堆栈机的一个例子。与其他基于堆栈的编程语言一样,最后输入的是第一个输出的。这是后进先出(LIFO)的概念。它使用零地址格式指令集,其中操作数始终位于已知位置。这不需要寄存器中的地址,因为堆栈中的值是临时的。因此,当执行操作时,将“popped”堆栈顶部的值,并将结果值“pushed”回堆栈中。另一个术语是“反向波兰符号(Reverse Polish Notation)”。

让我们举个例子。

x = 12 + 4 * 5?

通常情况下,这个方程的内容是:

按照PEMDAS原理,x等于4和5乘以12的乘积。

使用LIFO先进后出概念,堆栈机对它的读取方式大不相同。 在这种情况下,公式将类似于此示例。

x = 4 5 * 12 +

从调用堆栈中读取的方式为:

取值4和5,然后相乘,将值弹出堆栈,然后将结果乘积放在堆栈顶部。 然后取乘积和值12以获得x的总和,然后将值pop堆栈。 将总和 x push到堆栈顶部。

在这两种情况下,我们为此操作获得的结果均为32。将数据放入调用堆栈的操作使用的是PUSH方法,而删除数据的操作称为POP方法。

将代码从人类可读的ASCII字符编译为机器可读的十六进制字符只是第一步。 接下来,机器代码必须执行所谓的操作码(opcodes)。 操作码(opcodes)告诉计算机要执行哪些操作。 我们有操作码,操作所依据的数据取决于操作员将执行的操作。

这是一个执行托管功能的简单智能合约。

pragma solidity ^0.5.1;
contract Escrow {

? ? address agent;

? ? mapping(address => uint256) public deposits;

? ? modifier onlyAgent() {?
? ? ? ? require(msg.sender == agent);
? ? ? ? _;
? ? }

? ? constructor () public {
? ? ? ? agent = msg.sender;
? ? }

? ? function deposit(address payee) public onlyAgent payable {
? ? ? ? uint256 amount = msg.value;
? ? ? ? deposits[payee] = deposits[payee] + amount;
? ? }

? ? function withdraw(address payable payee) public onlyAgent {
? ? ? ? uint256 payment = deposits[payee];
? ? ? ? deposits[payee] = 0;
? ? ? ? payee.transfer(payment);
? ? }
}

下面是从编译后的代码生成的bytecode的示例。

{
?"linkReferences": {},
?"object": "608060405234801561001057600080fd5b50336000806101000a8154817

3ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffff

ffffffffffffffffffffff1602179055506103ac806100606000396000f3fe608060405
260043610610051576000357c0100000000000000000000000000000000000000000000
0000000000009004806351cff8d914610056578063f340fa01146100a7578063fc7e286
d146100eb575b600080fd5b34801561006257600080fd5b506100a56004803603602081
101561007957600080fd5b81019080803573fffffffffffffffffffffffffffffffffff
fffff169060200190929190505050610150565b005b6100e96004803603602081101561
00bd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1
6906020019092919050505061027f565b005b3480156100f757600080fd5b5061013a60
04803603602081101561010e57600080fd5b81019080803573fffffffffffffffffffff
fffffffffffffffffff169060200190929190505050610368565b604051808281526020
0191505060405180910390f35b6000809054906101000a900473fffffffffffffffffff
fffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373
ffffffffffffffffffffffffffffffffffffffff161415156101ab57600080fd5b60006
00160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffff
ffffffffffffffffffffffff16815260200190815260200160002054905060006001600
08473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffff
ffffffffffffffffff168152602001908152602001600020819055508173fffffffffff
fffffffffffffffffffffffffffff166108fc8290811502906040516000604051808303
81858888f1935050505015801561027a573d6000803e3d6000fd5b505050565b6000809
054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffff
ffffffffffffffffffffffffffffffff163373fffffffffffffffffffffffffffffffff
fffffff161415156102da57600080fd5b600034905080600160008473ffffffffffffff
ffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1
681526020019081526020016000205401600160008473ffffffffffffffffffffffffff
ffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019
08152602001600020819055505050565b60016020528060005260406000206000915090
50548156fea165627a7a72305820d6fa1114b349521b18dd6efdd04f06c882f1f7984c0
4829d2400baec88dc76950029",

?"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2?
0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP CALLER PUSH1 0x0 DUP1?
PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP PUSH2 0x3AC DUP1 PUSH2 0x60?
PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN INVALID PUSH1 0x80 PUSH1 0x40?
MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x51 JUMPI PUSH1 0x0 CALLDATALOAD
?PUSH29 0x100000000000000000000000000000000000000000000000000000000?
SWAP1 DIV DUP1 PUSH4 0x51CFF8D9 EQ PUSH2 0x56 JUMPI DUP1 PUSH4?
0xF340FA01 EQ PUSH2 0xA7 JUMPI DUP1 PUSH4 0xFC7E286D EQ PUSH2 0xEB?
JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST CALLVALUE DUP1 ISZERO?
PUSH2 0x62 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xA5 PUSH1?
0x4 DUP1 CALLDATASIZE SUB PUSH1 0x20 DUP2 LT ISZERO PUSH2 0x79 JUMPI?
PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD?
PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP1 PUSH1 0x20?
ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x150 JUMP JUMPDEST STOP?
JUMPDEST PUSH2 0xE9 PUSH1 0x4 DUP1 CALLDATASIZE SUB PUSH1 0x20 DUP2 LT?
ISZERO PUSH2 0xBD JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1?
DUP1 DUP1 CALLDATALOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF?
AND SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x27F
?JUMP JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xF7 JUMPI?
PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x13A PUSH1 0x4 DUP1?
CALLDATASIZE SUB PUSH1 0x20 DUP2 LT ISZERO PUSH2 0x10E JUMPI PUSH1 0x0?
DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD PUSH20?
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP1 PUSH1 0x20 ADD?
SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x368 JUMP JUMPDEST PUSH1?
0x40 MLOAD DUP1 DUP3 DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1?
0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH1 0x0 DUP1 SWAP1?
SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF?
AND CALLER PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND EQ?
ISZERO ISZERO PUSH2 0x1AB JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1?
0x0 PUSH1 0x1 PUSH1 0x0 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2?
MSTORE PUSH1 0x20 ADD SWAP1 DUP2 MSTORE PUSH1 0x20 ADD PUSH1 0x0?
KECCAK256 SLOAD SWAP1 POP PUSH1 0x0 PUSH1 0x1 PUSH1 0x0 DUP5 PUSH20?
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD SWAP1 DUP2?
MSTORE PUSH1 0x20 ADD PUSH1 0x0 KECCAK256 DUP2 SWAP1 SSTORE POP DUP2?
PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH2 0x8FC DUP3?
SWAP1 DUP2 ISZERO MUL SWAP1 PUSH1 0x40 MLOAD PUSH1 0x0 PUSH1 0x40 MLOAD?
DUP1 DUP4 SUB DUP2 DUP6 DUP9 DUP9 CALL SWAP4 POP POP POP POP ISZERO DUP1
?ISZERO PUSH2 0x27A JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY?
RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP POP POP JUMP JUMPDEST PUSH1
?0x0 DUP1 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20?
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFF AND CALLER PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFF AND EQ ISZERO ISZERO PUSH2 0x2DA JUMPI PUSH1 0x0 DUP1?
REVERT JUMPDEST PUSH1 0x0 CALLVALUE SWAP1 POP DUP1 PUSH1 0x1 PUSH1 0x0?
DUP5 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20?
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20?
ADD SWAP1 DUP2 MSTORE PUSH1 0x20 ADD PUSH1 0x0 KECCAK256 SLOAD ADD PUSH1?
0x1 PUSH1 0x0 DUP5 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF?
AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE?
PUSH1 0x20 ADD SWAP1 DUP2 MSTORE PUSH1 0x20 ADD PUSH1 0x0 KECCAK256?
DUP2 SWAP1 SSTORE POP POP POP JUMP JUMPDEST PUSH1 0x1 PUSH1 0x20 MSTORE?
DUP1 PUSH1 0x0 MSTORE PUSH1 0x40 PUSH1 0x0 KECCAK256 PUSH1 0x0 SWAP2?
POP SWAP1 POP SLOAD DUP2 JUMP INVALID LOG1 PUSH6 0x627A7A723058?
KECCAK256 0xd6 STATICCALL GT EQ 0xb3 0x49 MSTORE SHL XOR 0xdd PUSH15?
0xFDD04F06C882F1F7984C04829D2400 0xba 0xec DUP9 0xdc PUSH23 0x9500290000
000000000000000000000000000000000000 ",
?"sourceMap": "56:676:0:-;;;331:57;8:9:-1;5:2;;;30:1;27;20:12;5:2;331:57:
0;371:10;363:5;;:18;;;;;;;;;;;;;;;;;;56:676;;;;;;"
}

以下是为此智能合约生成的操作码。

PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x51 JUMPI?
PUSH1 0x0 CALLDATALOAD PUSH29 0x1000000000000000000000000000000000000000
00000000000000000 SWAP1 DIV DUP1 PUSH4 0x51CFF8D9 EQ PUSH2 0x56 JUMPI?
DUP1 PUSH4 0xF340FA01 EQ PUSH2 0xA7 JUMPI DUP1 PUSH4 0xFC7E286D EQ PUSH2?
0xEB JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST CALLVALUE DUP1 ISZERO
?PUSH2 0x62 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xA5 PUSH1?
0x4 DUP1 CALLDATASIZE SUB PUSH1 0x20 DUP2 LT ISZERO PUSH2 0x79 JUMPI?
PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD?
PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP1 PUSH1 0x20?
ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x150 JUMP JUMPDEST STOP?
JUMPDEST PUSH2 0xE9 PUSH1 0x4 DUP1 CALLDATASIZE SUB PUSH1 0x20 DUP2 LT?
ISZERO PUSH2 0xBD JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1?
DUP1 DUP1 CALLDATALOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
?AND SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2?
0x27F JUMP JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xF7 JUMPI?
PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x13A PUSH1 0x4 DUP1?
CALLDATASIZE SUB PUSH1 0x20 DUP2 LT ISZERO PUSH2 0x10E JUMPI PUSH1 0x0?
DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD PUSH20?
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP1 PUSH1 0x20 ADD?
SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x368 JUMP JUMPDEST PUSH1 0x40
?MLOAD DUP1 DUP3 DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40?
MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH1 0x0 DUP1 SWAP1 SLOAD?
SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND?
CALLER PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND EQ ISZERO?
ISZERO PUSH2 0x1AB JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 PUSH1?
0x1 PUSH1 0x0 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND
?PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1
?0x20 ADD SWAP1 DUP2 MSTORE PUSH1 0x20 ADD PUSH1 0x0 KECCAK256 SLOAD?
SWAP1 POP PUSH1 0x0 PUSH1 0x1 PUSH1 0x0 DUP5 PUSH20 0xFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFF AND DUP2 MSTORE PUSH1 0x20 ADD SWAP1 DUP2 MSTORE PUSH1 0x20 ADD?
PUSH1 0x0 KECCAK256 DUP2 SWAP1 SSTORE POP DUP2 PUSH20 0xFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH2 0x8FC DUP3 SWAP1 DUP2 ISZERO MUL?
SWAP1 PUSH1 0x40 MLOAD PUSH1 0x0 PUSH1 0x40 MLOAD DUP1 DUP4 SUB DUP2?
DUP6 DUP9 DUP9 CALL SWAP4 POP POP POP POP ISZERO DUP1 ISZERO PUSH2 0x27A
?JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1
?0x0 REVERT JUMPDEST POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 SWAP1?
SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF?
AND CALLER PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND EQ?
ISZERO ISZERO PUSH2 0x2DA JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1?
0x0 CALLVALUE SWAP1 POP DUP1 PUSH1 0x1 PUSH1 0x0 DUP5 PUSH20 0xFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD SWAP1 DUP2 MSTORE PUSH1?
0x20 ADD PUSH1 0x0 KECCAK256 SLOAD ADD PUSH1 0x1 PUSH1 0x0 DUP5 PUSH20?
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD SWAP1 DUP2?
MSTORE PUSH1 0x20 ADD PUSH1 0x0 KECCAK256 DUP2 SWAP1 SSTORE POP POP POP?
JUMP JUMPDEST PUSH1 0x1 PUSH1 0x20 MSTORE DUP1 PUSH1 0x0 MSTORE PUSH1?
0x40 PUSH1 0x0 KECCAK256 PUSH1 0x0 SWAP2 POP SWAP1 POP SLOAD DUP2 JUMP?
INVALID LOG1 PUSH6 0x627A7A723058 KECCAK256 0xd6 STATICCALL GT EQ 0xb3?
0x49 MSTORE SHL XOR 0xdd PUSH15 0xFDD04F06C882F1F7984C04829D2400 0xba?
0xec DUP9 0xdc PUSH23 0x9500290000000000000000000000000000000000000000

操作码是由CPU执行的汇编语言命令。 实际上,开发人员可以使用汇编而不是高级编程代码来达到相同的目的,但是要复杂得多。 对于大多数开发人员而言,IDE的易用性和友好的UI会更好,并且可能会减少耗时。

智能合约将部署在区块链上,区块链是一个分布式,去中心化的网络。 ABI(应用程序二进制接口)提供了一种通过网络与智能合约进行交互的标准方法。 它允许外部应用程序和合同到合同的交互。 开发人员在其应用程序或DApp(分散式应用程序)中使用ABI来访问智能合约中的方法和功能。

[
?{
? "constant": false,
? "inputs": [
? ?{
? ? "name": "payee",
? ? "type": "address"
? ?}
? ],
? "name": "withdraw",
? "outputs": [],
? "payable": false,
? "stateMutability": "nonpayable",
? "type": "function"
?},
?{
? "constant": false,
? "inputs": [
? ?{
? ? "name": "payee",
? ? "type": "address"
? ?}
? ],
? "name": "deposit",
? "outputs": [],
? "payable": true,
? "stateMutability": "payable",
? "type": "function"
?},
?{
? "constant": true,
? "inputs": [
? ?{
? ? "name": "",
? ? "type": "address"
? ?}
? ],
? "name": "deposits",
? "outputs": [
? ?{
? ? "name": "",
? ? "type": "uint256"
? ?}
? ],
? "payable": false,
? "stateMutability": "view",
? "type": "function"
?},
?{
? "inputs": [],
? "payable": false,
? "stateMutability": "nonpayable",
? "type": "constructor"
?}
]

将智能合约部署到区块链后,EVM将在字节码中执行编译后的代码的操作码。如果功能需要更改区块链的状态,则将向合同所有者收取称为gas(以wei为单位)的计算单位。这些成本遵循以太坊协议,该协议要求在整个网络上花费计算成本,这是支付给矿工的费用,矿工将验证放入区块中的交易。简单的调用函数不需要更改区块链的状态,不会消耗gas,这是免费的。一个例子是对智能合约中的储值进行余额查询。

就成本而言,使用PUSH方法将数据存储在堆栈上最便宜。接下来是MSTORE方法,该方法将数据存储在RAM(系统内存)中。在这两种方法中,由于数据值是临时的,因此它们在区块链上并不持久。使用SSTORE方法(将数据存储在磁盘存储中)时,它变得持久。 SSTORE方法也是最昂贵的,因为它将持久性数据存储在区块链上。

现在回到该示例中的智能合约详细信息。当智能合约由EVM部署并执行时,它现在位于区块链上。它将变得不可变,同时透明,这意味着它不能直接更改,并且可以被公众看到。智能合约还分配有其自己的地址。在此示例中是:

0x692a70d2e424a56d2c6c27aa97d1a86395877b3a

该智能合约已部署在测试系统上,但是如果智能合约已部署到以太坊区块链上的主网,则可以使用区块浏览器进行搜索。 其中包含有关智能合约的更多详细信息,包括余额,以太价值和合约创建者的公共地址。 所有交易也都按其交易哈希值列出和搜索。

该图说明了与以太坊网络架构有关的EVM。

文章标签: 堆栈 区块链 合约 以太 操作
本网所发布资讯来源网络,仅属作者个人主观观点,与本网无关。
?

专栏合作

欢迎您浏览龙亚博体育网址8官网,有关资讯合作,投稿或其他疑问请联系 QQ:2698491281

开通专栏