Solidity contract智能合约概览

solidity智能合约 在这种情况下,攻击方的胜利次数和等级都会增加,被攻击方的失败次数会增加,并调用feedAndMultiply函数,以将攻击方的DNA和被攻击方的DNA混合在一起,创建一个新的僵尸。feedOnKitty 函数接收Zombie ID 和猫的 ID 作为参数,调用 KittyContract 的 getKitty 函数以获取猫的 DNA,然后调用 feedAndMultiply 函数以将给定 Zombie 的 DNA 和猫的 DNA 相加取平均数以生成新的 DNA,并创建一个新的 Zombie。 阅读详情

Contracts in Solidity are similar to classes in object-oriented languages. They contain persistent data in state variables, and functions that can modify these variables. Calling a function on a different contract (instance) will perform an EVM function call and thus switch the context such that state variables in the calling contract are inaccessible. A contract and its functions need to be called for anything to happen. There is no “cron” concept in Ethereum to call a function at a particular event automatically. 在solidity中Contract类似于在面向对象语言中的classes概念. 合约包含状态变量,用于存储数据, 和函数,用于修改这些变量。  不同的合约实例调用一个函数,会执行一个EVM的函数调用, 如此,切换上下文环境后,状态变量在调用合约的过程中不能互相访问.合约和合约的函数需要被调用,才能运行。在以太坊中,存在cron的概念, 定时任务自动调用的方式.

Visibility and Getters 

State Variable Visibility

public

internal

private

Function Visibility

external

External functions are part of the contract interface, which means they can be called from other contracts and via transactions. An external function f cannot be called internally (i.e. f() does not work, but this.f() works).

public 

Public functions are part of the contract interface and can be either called internally or via message calls.

internal

private

Function Modifiers

Modifiers can be used to change the behavior of functions in a declarative way. For example, you can use a modifier to automatically check a condition prior to executing the function.

Constant and Immutable State Variables

State variables can be declared as constant or immutable. In both cases, the variables cannot be modified after the contract has been constructed. For constant variables, the value has to be fixed at compile-time, while for immutable, it can still be assigned at construction time.

constant在编译的时候,已经固化了变量值不可改变。 immutable是合约创建之后才固化下来,在合约的构造函数里面仍然可以修改.

Functions

Functions can be declared view in which case they promise not to modify the state.

Functions can be declared pure in which case they promise not to read from or modify the state.

Fallback Function

A contract can have at most one fallback function, declared using either fallback () external [payable] or fallback (bytes calldata input) external [payable] returns (bytes memory output) (both without the function keyword). This function must have external visibility. A fallback function can be virtual, can override and can have modifiers.

一个只能合约最多有一个fallback函数,声明fallback () external [payable] 或者fallback (bytes calldata input) external [payable] returns (bytes memory output) , 二者都没有function关键字. 回调函数必须是external 可视属性. 一个回调函数可以是虚拟的, 可被重写, 可以有修饰符modifiers去修饰。

contract TestPayable {
    uint x;
    uint y;
    // This function is called for all messages sent to
    // this contract, except plain Ether transfers
    // (there is no other function except the receive function).
    // Any call with non-empty calldata to this contract will execute
    // the fallback function (even if Ether is sent along with the call).
    // 任意非空calldata的call调用,都会触发这个回调函数.
    // call内部有参数,则调用fallback, 没有参数, 则调用receive.
    fallback() external payable { x = 1; y = msg.value; }

    // This function is called for plain Ether transfers, i.e.
    // for every call with empty calldata.
    // 每一个空的calldata的调用,会调用这个receive方法.
    receive() external payable { x = 2; y = msg.value; }
}

 function callTestPayable(TestPayable test) public returns (bool) {
        (bool success,) = address(test).call(abi.encodeWithSignature("nonExistingFunction()"));
        require(success);
        // results in test.x becoming == 1 and test.y becoming 0.
        (success,) = address(test).call{value: 1}(abi.encodeWithSignature("nonExistingFunction()"));
        require(success);
        // results in test.x becoming == 1 and test.y becoming 1.

        // If someone sends Ether to that contract, the receive function in TestPayable will be called.
        // Since that function writes to storage, it takes more gas than is available with a
        // simple ``send`` or ``transfer``. Because of that, we have to use a low-level call.
        (success,) = address(test).call{value: 2 ether}("");
        require(success);
        // results in test.x becoming == 2 and test.y becoming 2 ether.

        return true;
    }

Inheritance

Solidity supports multiple inheritance including polymorphism. solidity 支持多继承和多模态.

Polymorphism means that a function call (internal and external) always executes the function of the same name (and parameter types) in the most derived contract in the inheritance hierarchy. This has to be explicitly enabled on each function in the hierarchy using the virtual and override keywords. See Function Overriding for more details.

多态性意味着函数调用(内部和外部)总是在继承层次结构中派生最多的契约中执行相同名称(和参数类型)的函数。必须使用virtual和override关键字在层次结构中的每个函数上显式启用此功能。有关更多详细信息,请参阅函数重写。

When a contract inherits from other contracts, only a single contract is created on the blockchain, and the code from all the base contracts is compiled into the created contract. This means that all internal calls to functions of base contracts also just use internal function calls (super.f(..) will use JUMP and not a message call).  当一个合约从其他多个合约继承的时候, 只有一个合约会在链上创建,所有的基类合约代码会被编译为新建的合约中。意味着所有对基类合约的函数的内部调用将使用内部函数调用。(super.f(..) 将使用JUMP, 而不是消息调用).

多继承例子:

contract PriceFeed is Owned, Destructible, Named("GoldFeed") {
    function updateInfo(uint newInfo) public {
        if (msg.sender == owner) info = newInfo;
    }

    // Here, we only specify `override` and not `virtual`.
    // This means that contracts deriving from `PriceFeed`
    // cannot change the behavior of `destroy` anymore.
    function destroy() public override(Destructible, Named) { Named.destroy(); }
    function get() public view returns(uint r) { return info; }

    uint info;
}

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

contract owned {
    constructor() { owner = payable(msg.sender); }
    address payable owner;
}

contract Destructible is owned {
    function destroy() virtual public {
        if (msg.sender == owner) selfdestruct(owner);
    }
}

contract Base1 is Destructible {
    function destroy() public virtual override { /* do cleanup 1 */ super.destroy(); }
}


contract Base2 is Destructible {
    function destroy() public virtual override { /* do cleanup 2 */ super.destroy(); }
}

contract Final is Base1, Base2 {
    function destroy() public override(Base1, Base2) { super.destroy(); }
}

If Base2 calls a function of super, it does not simply call this function on one of its base contracts. Rather, it calls this function on the next base contract in the final inheritance graph, so it will call Base1.destroy() (note that the final inheritance sequence is – starting with the most derived contract: Final, Base2, Base1, Destructible, owned). 

Base2 调用super,不是简单的调用基类中的某一个函数. 而是调用最终继承树旁边的基类的方法,因此就是调用Base1.destory().  注意: 最终继承序列是:Final ->Base2 -> Base1 -> Destructible->owned.

Function Overriding 函数重写

The overriding function may only change the visibility of the overridden function from external to public.  复写函数可能只可以改变被复写函数的可视性. 比如从external到public.

The mutability may be changed to a more strict one following the order: nonpayable can be overridden by view and pure. view can be overridden by pure. payable is an exception and cannot be changed to any other mutability.

可变性可以按照以下顺序更改为更严格的可变性:nonpayable可以被view,pure重写, view可以被pure重写. payable是一个列外, 不可能被任何可变性重写.

Arguments for Base Constructors

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

contract Base {
    uint x;
    constructor(uint _x) { x = _x; }
}

// Either directly specify in the inheritance list...
contract Derived1 is Base(7) {
    constructor() {}
}

// or through a "modifier" of the derived constructor.
contract Derived2 is Base {
    constructor(uint _y) Base(_y * _y) {}
}

Multiple Inheritance and Linearization (多继承和线性化,从右向左, python是从左向右.)

Another simplifying way to explain this is that when a function is called that is defined multiple times in different contracts, the given bases are searched from right to left (left to right in Python) in a depth-first manner, stopping at the first match. If a base contract has already been searched, it is skipped. 另一个简单的方法去解释这个是: 多继承中,当调用一个定义在多个不同合约中相同的函数时,对基类函数的搜索顺序是以深度优先方式 从右向左,(在python中是从左向右)。 如果一个合约已经被搜索到, 搜索会中断跳出.

注意构造函数调用顺序:

// SP
DX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

contract Base1 {
    constructor() {}
}

contract Base2 {
    constructor() {}
}

// Constructors are executed in the following order:
//  1 - Base1
//  2 - Base2
//  3 - Derived1
contract Derived1 is Base1, Base2 {
    constructor() Base1() Base2() {}
}

// Constructors are executed in the following order:
//  1 - Base2
//  2 - Base1
//  3 - Derived2
contract Derived2 is Base2, Base1 {
    constructor() Base2() Base1() {}
}

// Constructors are still executed in the following order:
//  1 - Base2
//  2 - Base1
//  3 - Derived3
contract Derived3 is Base2, Base1 {
    constructor() Base1() Base2() {}
}

Abstract Contracts 抽象合约

Contracts need to be marked as abstract when at least one of their functions is not implemented.

合约必须被标注为abstract,  当至少一个函数没有被实现.

Contracts may be marked as abstract even though all functions are implemented.

合约可能会被标注为abstract,及时所有的函数都已经实现了.

Such abstract contracts can not be instantiated directly. This is also true, if an abstract contract itself does implement all defined functions.  抽象合约不能被实例化. 即使是抽象合约实现了所有的定义函数,也不能被直接实例化.

If a contract inherits from an abstract contract and does not implement all non-implemented functions by overriding, it needs to be marked as abstract as well.

如果一个合约继承一个抽象合约,并且没有实现全部抽象函数,则这个合约也得被标注为abstract.

抽象合约不能用一个抽象函数去重写一个已经实现了的函数.

Interfaces (接口)

  • They cannot inherit from other contracts, but they can inherit from other interfaces. 不能继承其他合约,只能继承接口.

  • All declared functions must be external. 所有的函数声明,必须外部可视.

  • They cannot declare a constructor.  不能声明构造函数.

  • They cannot declare state variables. 不能声明状态变量.                                                                       

    All functions declared in interfaces are implicitly virtual, which means that they can be overridden. This does not automatically mean that an overriding function can be overridden again - this is only possible if the overriding function is marked virtual.       

    所有在接口中定义的函数隐式的被virtual修饰, 意味着它们都可以被重写。这并不是意味自动的, 重写函数可以被自动的被重写,必须要有virtual去修饰。                   

Libraries

Libraries are similar to contracts, but their purpose is that they are deployed only once at a specific address and their code is reused using the DELEGATECALL (CALLCODE until Homestead) feature of the EVM.  Libraries 和contracts 非常相似, 它们被部署在一个特殊的地址上,它们的代码通过EVM的特性delegatecall 或callcode来调用重用。 liberies的执行环境是调用合约的执行环境。

 Library functions can only be called directly  只有在libereries函数是view或pure的时候,才能直接调用。 不允许修改状态的lib函数,直接被调用, 必须通过delegatecall调用。

Libraries can be seen as implicit base contracts of the contracts that use them. They will not be explicitly visible in the inheritance hierarchy, but calls to library functions look just like calls to functions of explicit base contracts (using qualified access like L.f()). Of course, calls to internal functions use the internal calling convention, which means that all internal types can be passed and types stored in memory will be passed by reference and not copied. To realize this in the EVM, code of internal library functions and all functions called from therein will at compile time be included in the calling contract, and a regular JUMP call will be used instead of a DELEGATECALL.

Libraries可以被看成是隐式的基类继承合约,但lib不会出现在继承层级中, 但调用lib的函数,跟调用基类合约的函数是一样的(正确的访问应该是 L.f()). 当然,调用内部函数,使用调用内部函数的惯例。convention 惯例.  意味所有被传递的内部类型都是存储在memory中, 可以被引用传递,而不是值拷贝。 EVM为了实现这个功能,lib的内部函数代码和在那里被调用的参数将会在编译期间被包含在调用合约里面(calling contract),  一个常规的JUMP 会取代DELEGATECALL.

As the compiler does not know the address where the library will be deployed, the compiled hex code will contain placeholders of the form __$30bbc0abd4d6364515865950d3e0d10953$__. 

因为编译器不知道library将会部署到那个地址上,所有编译16进制代码会包含一个占位符号:__$30bbc0abd4d6364515865950d3e0d10953$__  (是libraries/bigint.sol:BigInt的hash格式.)

Such bytecode is incomplete and should not be deployed. Placeholders need to be replaced with actual addresses. You can do that by either passing them to the compiler when the library is being compiled or by using the linker to update an already compiled binary. See Library Linking for information on how to use the commandline compiler for linking. 如此字节代码是不完整的,不应该被部署。 占位符需要用真实的地址替换掉。 你可以把真实地址传递给编译器当library正在被编译的过程中, 或者使用linker更新一个已经编译好的字节码和真实地址建立联系.

In comparison to contracts, libraries are restricted in the following ways:

  • they cannot have state variables  不能拥有状态变量.

  • they cannot inherit nor be inherited 不能继承或被继承。

  • they cannot receive Ether  不能接受ETH

  • they cannot be destroyed 不能被销毁.

(These might be lifted at a later point.)  这些限制在未来中可能会被lifted.

Function Signatures and Selectors in Libraries

Similarly to the contract ABI, the selector consists of the first four bytes of the Keccak256-hash of the signature.  和contract ABI相似, selector 由 函数签名后的Keccak256-hash的前4个字节组成.

Call Protection For Libraries

As mentioned in the introduction, if a library’s code is executed using a CALL instead of a DELEGATECALL or CALLCODE, it will revert unless a view or pure function is called.

只有view和pure库函数,可以用call调用,其他的都不可以,否则会被revert.

DelegateCall和callcode, 可以调用所有的库函数.

The EVM does not provide a direct way for a contract to detect whether it was called using CALL or not, but a contract can use the ADDRESS opcode to find out “where” it is currently running. The generated code compares this address to the address used at construction time to determine the mode of calling.

EVM没有为合约提供一个直接的方法去识别合约是被用call调用,还是不是. 但是合约可以用ADDRESS 操作码去识别它当前在哪里运行。生成的代码会去比较this.address和构造函数里面的地址去识别合约运行模式。

More specifically, the runtime code of a library always starts with a push instruction, which is a zero of 20 bytes at compilation time. When the deploy code runs, this constant is replaced in memory by the current address and this modified code is stored in the contract. At runtime, this causes the deploy time address to be the first constant to be pushed onto the stack and the dispatcher code compares the current address against this constant for any non-view and non-pure function.

This means that the actual code stored on chain for a library is different from the code reported by the compiler as deployedBytecode.

更具体的说,库运行代码总是带着一个推送结构(20个字节结构,在编译期间,都为0)一起启动,  当开始部署时候, 这个20字节常量constant 会被当前地址所替换 并且 这个修改后的代码被存储在合约里面。在运行期间,部署期间的地址成为优先常量会被push到stack里面, 调度员代码会比较当前地址和常量constant地址为每一个非view和非pure的方法.

这意味着存储在库链上的实际代码与编译器报告为deployedBytecode的代码不同。

Using For

The directive using A for B; can be used to attach library functions (from the library A) to any type (B) in the context of a contract. These functions will receive the object they are called on as their first parameter (like the self variable in Python).

直接使用using A for B, 可以把库A的函数全部赋到B合约上. 这些库函数将会把B作为他们的第一个参数.

The effect of using A for *; is that the functions from the library A are attached to any type.

using A for *,  把库A的函数依附到所有类型上.

The using A for B; directive is active only within the current contract, including within all of its functions, and has no effect outside of the contract in which it is used. The directive may only be used inside a contract, not inside any of its functions.

using A for B 指令只会在合约内有效,包括合约内的所有函数有效, 对合约外部没有影响。这个指令只能写在合约里面,不能写在函数里面。

Note that all external library calls are actual EVM function calls. This means that if you pass memory or value types, a copy will be performed, even of the self variable. The only situation where no copy will be performed is when storage reference variables are used or when internal library functions are called.

请注意,所有外部库调用都是实际的EVM函数调用。这意味着,如果传递内存或值类型,将执行复制,甚至是自变量的复制。唯一不执行复制的情况是使用存储引用变量或调用内部库函数时。

调用库外部函数,除了storage类型,都是值复制。  调用库内部函数都是值引用。

Inline Assembly

Inline assembly is a way to access the Ethereum Virtual Machine at a low level.  内联汇编是一种以底层的方式去访问Etherum Virtual Machine的方式.This bypasses several important safety features and checks of Solidity. 这回绕过很重要的solidity的安全特性和安全检查。You should only use it for tasks that need it, and only if you are confident with using it. 你只能在任务真实需要的时候使用它,并且你有把握去使用它。

An inline assembly block is marked by assembly { ... }

001.Solidity 智能合约概述 Solidity 智能合约概述 阅读详情

相关推荐

智能合约(Smart contract)

一、简介 概念:是指一份能自动执行本需要手动才能完成任务的协议。智能合约就是任何能自动执行部分功能的协议。例如,一份能自动计算合同当事人待付金额,并安排支付这笔金额的合约。智能合约将减少协议执行过程中的人工干预。 目的:提供优于传统合约的安全方法,并减少与合约相关的其他交易成本交易成本。 智能合约概念于1995年由Nick Szabo首次提出。他的定义如下:“一个智能合约是一套以数字形式定义的承诺(promises),包括合约参与方可以在上面执行这些承诺的协议。” 承诺:一套承诺指的是合约参与方

hanbing1307的博客 4374

solidity -- 合约

在不同的合约(实例)上调用函数将执行 EVM 函数调用,从而切换上下文,使得调用合约中的状态变量不可访问。编译器生成的合约创建代码将在合约返回之前修改合约的运行时代码,方法是将所有对不可变对象的引用替换为分配给它们的值。内部可见性函数访问可以在当前合约或派生的合约访问,不可以外部访问。的变量受到的限制要少一些:可以在合约的构造函数中或在声明时为不可变变量分配任意值。只能使用在当前合约或在基类合约中定义的 修改器modifier , 修改器modifier 也可以定义在库里面,但是他们被限定在库函数使用。

一只路过的小码农cxy 1469

怎样使用 Hardhat 开发 Solidity 智能合约

创建一个简单的智能合约并对其进行测试,然后使用 Hardhat 将其部署在测试网上.

Lance 3698

solidity语言学习(9)—— 合约(Contract)

在solidity中合约类似于面对对象的语言中的类。他包括了状态变量中那些长期的数据以及能够修改这些状态的函数。在一个合约中调用另一个合约(实例)的函数会执行一个EVM函数调用,它将转换上下文内容是得状态变量不可触及。 创造合约 合约是通过以太坊交易或者来自solidity合约内部,“从外部”产生的。 一些典型的IDE,比如说Remix,能够使用UI元素创造无缝的进程。 在以太坊中程式...

weixin_42595515的博客 4557

如何用 Solidity 创建一个“Hello World”智能合约

Solidity 编程语言的 “Hello world”

ChainlinkO的博客 1767

【0基础】学习solidity开发智能合约-初识solidity

solidity入门课程,初识solidity

外柏叁布道者 6872

智能合约开发-Metamask、Solidity

为了构建开发智能合约或者dApp,我们需要安装以下模块:Node 与 NPM,Truffle 框架,Ganache,Metamask,VScode 与 Solidity插件。

charles0902的专栏 1822

微众银行《Solidity智能合约库》区块链工程师的随身工具箱之初体验相当的nice

文章目录一、智能合约库简介二、痛点及解决方式痛点一:计算可能溢出痛点二:转换不够便捷痛点三:数组操作不够丰富痛点四:不提供字符串内置操作痛点五:高级数据结构不完备总结 一、智能合约库简介 作为一门实现了图灵完备的智能合约编程语言,Solidity编程语言的开发、设计、迭代、演化的逻辑完全基于区块链,并在区块链领域具有广泛的影响力和详尽的文档,被众多区块链底层平台所支持,其中就包括FISCO BCOS。 但是,Solidity编程语言也存在若干挑战。首先,受区块链昂贵的资源限制,Solidity舍去了诸多在

向彪-区块链技术研究 8701

Solidity Contract

在Solidity中,Contract对象是一个合约的蓝图或模板。它规定了合约的状态变量、函数、事件和修饰符等元素。每当您在以太坊区块链上部署一个智能合约时,实际上是基于该合约的Contract对象创建了一个新的实例。Contract对象是Solidity智能合约的核心组成部分,定义了合约的结构和行为。它包括状态变量、函数、事件和修饰符等元素,用于实现合约的逻辑和交互。通过编写、部署和与Contract对象交互,开发者可以创建强大的分散式应用程序,利用以太坊区块链的功能。

qq_41586330的博客 197

基于FISCO BCOS 部署可升级的 Solidity存证智能合约

本文介绍了基于FISCOBCOS平台的可升级Solidity存证智能合约实现方案。采用透明代理模式,包含逻辑合约、代理合约和管理合约三部分,支持业务逻辑升级而不影响存储数据。详细阐述了合约架构设计、Solidity代码实现、Go SDK交互流程以及完整的部署升级步骤。方案具有数据持久性、版本兼容性和生产就绪等特点,提供了权限控制、输入验证等安全机制,并包含监控管理工具。该实现为企业级区块链存证应用提供了可靠的基础架构,支持后续功能扩展和定制化开发。

分享AI、区块链技术及应用,未来已来 1514

【接地系统篇】电力系统接地技术详解:从基本原理到实际应用

接地是为电流返回电源提供的一条低阻抗通道。简单来说,就是为故障电流修建一条"安全回家"的路,防止电流通过人体或其他不应带电的部件。接地系统选择原则安全性优先:TN-S系统安全性最高,适合重要场所经济性考虑:TN-C系统成本最低,适合一般工业连续性要求:IT系统供电连续性最好,适合特殊场所灵活性选择:TN-C-S系统兼顾经济与安全,应用最广。

2301_81299416的博客 2224

solidity:智能合约结构介绍

第 1 行就是合约的版权声明。其中(SPDX 许可标示) 是标注当前的智能合约采用什么样的对外开放标准,该标准规定了别人是否拥有商业开发,学习使用等权利。代码中使用的MIT规定了其他人随便用该代码,但出问题不负责。MIT 详细解释;SPDX 许可标示的注释在文件的任何位置都可以被编译器识别到的,按照规范建议把它放在文件的顶部第一行。如果一个项目开源了智能合约的源代码,可以更好地建立社区信任。但是由于提供源代码就不可避免的涉及到版权或者法律问题。所以 solidity 鼓励开源,但是开源并不等于放弃版权。

目前专注区块链相关技术的学习与分享 3669

智能气象站:ESP32驱动的心知天气数据可视化实践

本文详细介绍了基于ESP32微控制器和心知天气API构建智能气象站的完整实践。通过Arduino开发环境,实现天气数据的获取、JSON解析与OLED屏可视化展示,涵盖硬件连接、API配置、低功耗优化及部署问题排查,为物联网开发者提供实用指南。

jump7的博客 211

基于truffle-contract库之solidity事件与合约调用完整案例!

/** * 一个基于truffle-contract库实现的以太坊solidity智能合约调用案例! * 注意:truffle-contract库和web3.js使用nodej或import同时导入转码的时候会打架冲突! * 为此如果使用truffle-contract库来实现solidity调用,必须使用truffle-contract原生链的Web3对象! * ...

weixin_43343144的博客 1171

基于ADS\HFSS\Matlab的平面带通发夹滤波器设计

写在最前面,前段时间完成了一个小项目,实现13.5~14GHz的带通滤波器,算是第一个微波项目,在老师、学长、各种大神的指点下,最终完成了指标,想来这段时间收获良多,想到老师教导的,有能力的话要尽可能帮助别人,以及网络上很少面向于小白的教程,于是决定把自己做这个小项目的经过,一些关键步骤,还有软件操作和公式讲解都发出来,供大家指正借鉴。由于我目前大三,刚学习电磁场、微波工程等等,技术实在有限,同时这样是我第一次发帖子,只能尽可能的将自己确认过正确的内容,步骤以及一些经验写出来,供大家借鉴。

likaifeng12138的博客 5219

嵌入式开发中Tab与空格混用的危害与统一规范实践

在软件工程中,代码格式一致性是保障可读性与团队协作效率的基础。从原理上看,制表符(Tab)与空格(Space)在存储与显示机制上存在本质差异:Tab是控制字符,其显示宽度取决于编辑器设置;空格则是固定宽度的字符。这种差异导致混用时会引发代码对齐错乱、版本控制冲突及跨平台兼容性问题,严重影响工程的可维护性。尤其在嵌入式开发领域,资源受限环境与高可靠性要求使得统一的编码规范更为关键。通过配置编辑器、集成clang-format等自动化工具,可以强制实现缩进风格的一致性,从而提升代码质量与团队协作效率。本文聚焦于

weixin_42545636的博客 276

Solidity入门-开发众筹智能合约

前言本文要求你对Solidity开发有一点基础的了解。我会使用Solidity开发一个简单的众筹智能合约,合约的主要功能就是向希望给我捐赠的人收钱,然后我再将钱从合约账户里取出来。因为程序...

weixin_30230009的博客 6875

机器学习的学习准则(期望风险最小化、经验风险最小化、结构风险最小化)

要评价模型f(x, θ)的好坏,可通过期望风险R(θ)来衡量:求期望损失R(θ)不仅需要知道损失函数还需要知道真实分布,损失函数可以通过一定的准则计算得到,但是样本空间的真实分布是未知的。所以不能直接求R(θ)。期望风险R(θ)无法计算,给定一个训练集D =,我们可以计算经验风险,经验风险就是在训练集上的平均损失:为了解决过拟合问题,引入了参数正则化来限制模型的能力。使其不要过度的最小化经验风险。这种准则就是结构风险最小化准则

... 2225

Solidity【简介】

Solidity概述、Solidity语言核心特性、Solidity开发工具Remix、智能合约学习游戏、什么是以太坊、以太坊虚拟机EVM

尽欢的博客 1715

codesys多协议通信之OPC UA通信

测试不易,转载请注明出处!

weixin_44243068的博客 3638

桌面运维工程师面试题汇总(高频完整版)

岗位,覆盖:电脑硬件、系统安装与故障、网络、办公软件、安全、AD域、打印机、日常排错、服务意识。

老韩的Linux云计算架构师进阶之路 921

【重磅推荐】基于truffle-contract库实现的以太坊solidity合约调用案例(注:web3.js切勿和truffle-contract库同时使用,否则报错,无法修复!)

1、一个基于truffle-contract库实现的以太坊solidity智能合约调用案例! 2、 注意:truffle-contract库和web3.js使用nodej或import同时导入转码的时候会打架冲突! 为此如果使用truffle-contract库来实现solidity调用,必须使用truffle-contract原生链的Web3对象! truffle-...

weixin_43343144的博客 1008

Ubuntu搭建Pytorch环境(Anaconda、Cuda、cuDNN、Pytorch、Python、Pycharm、Jupyter)

Ubuntu搭建Pytorch环境(Anconda、Cuda、Pytorch、Python、Pycharm、Jupyter)

funfan的博客 1万+

区块链(七)智能合约(Smart Contract)

1. 智能合约(Smart Contract) 智能合约(Smart Contract),是一种旨在以信息化方式传播、验证或执行合同的计算机协议。智能合约允许在没有第三方的情况下进行可信交易,这些交易可追踪且不可逆转。智能合约部署在区块链节点,当智能合约中设定的事件被触发时,智能合约就会自动执行,此过程无需第三方参与。 2. solidity 在编写智能合约的语言当中最火的就是solidit...

橘红色の火焰的博客 4155

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

solidity之library 用法(二)库的核心用法总结(一个特殊的contract合约)

solidity之library的一个核心原则就是:哪个合约调用library,那么library中的this就指向那个合约! pragma solidity &gt;=0.4.0 &lt;0.6.0; library Test_lib { // 这里的参数存储位置必须和contract合约调用传参位置一致! // 官方文档强调:library的内存类型都是通过引用来传递的...

weixin_43343144的博客 2400

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

智能合约编写之Solidity的基础特性

来源 |FISCO BCOS 作者 |储雨知 责编 | Carol 出品 |区块链大本营(blockchain_camp) 目前大部分的联盟链平台,包括FISCO BCOS,都采用Solidity作为智能合约开发语言,因此熟悉并上手Solidity十分必要。 作为一门面向区块链平台设计的图灵完备的编程语言,Solidity支持函数调用、修饰符、重载、事件、继承等多种...

akjw008的专栏 2940

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

上一篇: solidity中error,panic,require,revert,assert之间的关系.
下一篇: Inline Assembly 内联汇编总结
gridlayout
博客等级 码龄19年 12粉丝 26原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值