A very simple way to simulate a Solidity smart contract transaction

A very simple way to simulate a Solidity smart contract transaction

We know that when MetaMask calls a contract, it will simulate execution once. If the call fails, it will display the failure in advance and ask you if you want to enforce it. This function is very useful, so can we implement a similar function ourselves?

The answer is yes, and it's fairly simple.

Example contract

Let's look at the test contract first:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract MockTest {
   
    
    
    uint public x = 5;

    address public owner;

    constructor

Guess you like

Origin blog.csdn.net/weixin_39430411/article/details/123557273