您当前的位置: 首页 > 
  • 0浏览

    0关注

    1477博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Metamask + remix:在ropsten测试链上取出已经部署的合约并进行一些操作

软件工程小施同学 发布时间:2022-03-27 22:31:09 ,浏览量:0

本地再次编译已部署合约

在这里插入图片描述

这里我们部署的还是之前说到的这个librarytest

查找已部署合约在ropsten上的地址:在这里插入图片描述 这是本人的最近三个交易,看看合约创建的交易:在这里插入图片描述 很好,看到我的地址了:

0xcc67ff70259fa82d4bd29e9075268816af9df9b8

回到remix使用ataddress功能在这里插入图片描述

点击at address 把合约搞出来:

在这里插入图片描述 你看,确实搞出来了,然后我们把11 replace 成22,来:

在这里插入图片描述 来确认一下交易:

在这里插入图片描述

确实,这个记录上链了:

在这里插入图片描述

最后看看etherscan的交易记录

在这里插入图片描述 确实,就是11和22

总结: 欢迎大家来用我的合约

附上被调用合约源码:

pragma solidity ^0.4.16;

library Search {
    function indexOf(uint[] storage self, uint value)
        public
        view
        returns (uint)
    {
        for (uint i = 0; i < self.length; i++)
            if (self[i] == value) return i;
        return uint(-1);
    }
}

contract C {
    using Search for uint[];//enlarge the operation of elementary type
    uint[] public data;
    
    function append(uint value) public {
        data.push(value);
    }
    
    function replace(uint _old, uint _new) public {
        //use library
        //same as Search.indexOf(data, _old)
        uint index = data.indexOf(_old);
        if (index == uint(-1))
            data.push(_new);
        else
            data[index] = _new;
    }
}
关注
打赏
1665320866
查看更多评论
立即登录/注册

微信扫码登录

0.0455s