bsc heco eth浏览器开源智能合约代码,图文说明

资讯 2024-06-19 阅读:64 评论:0
文章目录 配置基本配置其他配置library构造参...
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址


在浏览器上开源合约代码,会碰到一些常见问题,这里做一个汇总以及相关解决方案

基本配置

以下基本配置必须一样

The following basic configurations must be the same.

  • 编译版本 (这个指的是remix编译的版本,而不是合约代码里面写的版本)
  • EVM 版本 (一般都是default,如果有需要选了版本时,开源也要对应版本)
  • 是否优化,优化 (一般 是否优化, 优化配置默认是200)
  • 代码

代码除了注释以外,需要保证和部署的一样
这里说下有些代码使用了openzeppelin的相关代码

The code, in addition to the note xff0c; it needs to be guaranteed the same
as deployed >, which says that some of the codes use the appropriate code for openzepelin.

 

如果代码中使用了这种,建议要么部署完后,

If this xff0c is used in the code; it is recommended that either xff0c be deployed;

  1. 立马开源
  2. 要么自己手动把对应的文件整理到本地,或者使用flattener工具整合成一个文件备份

第2种情况,主要是避免,如果隔了很久再想开源,而且上面链接指向的代码更新过了,就没法开源了…

The second scenario xff0c; mainly avoiding xff0c; if you want to open source xff0c after a long time; and if the code on which the link is directed is updated xff0c; you can't open source...

特殊情况,如果确认代码没问题,也没有构造参数之类的,也是提交不了,那么你只能在提交页面,不断切换是否优化,切换不同的编译版本,去尝试提交开源 (代码中使用^,remix可能会给你默认选中当前版本的最后版本,比如0.6.0的代码,remix默认选中了0.6.12版本,部署的时候没注意看就给发布了)

special case, if the code is confirmed as no problem xff0c; if there are no construction parameters xff0c; or if you cannot submit xff0c; then you can only submit page xff0c; continuously switch whether to optimize xff0c; toggle different compilation versions xff0c; to try to submit open source (using, remix may give you default to select the last version of the current version xff0c; e.g. 0.6.0 code xff0c; remix default selected 0.6.12 xff0c; unattended when deployed)

其他配置说明
查看下图,红色的是一定要记住的,否则没法开源,只能一个一个试
黄色框里面是代码里面的版本 ^表示之上的版本都可以,所以这里remix可以使用0.8.7
勾选优化也会省手续费,以及有些时候超限也得勾选优化

Other configuration instructions
view the figure below xff0c; red is the xff0c that must be remembered; otherwise xff0c cannot be opened; only one
yellow box with a version in the code versions above xff0c; so remix can use 0.8.7 br/> to check optimisation also saves processing costs xff0c; and sometimes limits are ticked as well.

在这里插入图片描述

 insert the picture here

其他配置

  • 构造参数 (浏览器验证有时需要填,有时不需要填,原因不详… 有时提交不过,加上构造参数就好了)
  • library (部分合约部署的时候额外部署了library就需要)

这两个是可能需要的

These two might be necessary.

library

如果缺少library, 浏览器上会明确提示缺少library, 这个在配置里面添加即可
一般部署合约的时候,如果发了两个交易,第一个就是library
(还一种情况是remix连着部署两次主合约,第二次部署没有两次交易,使用了第一次时的library)

If there is a lack of library, the browser will send a clear reminder of a lack of library, which can be added to the configuration
to a general deployment contract xff0c; if two transactions are issued xff0c; first is library
(and in the case of remix deploying two main contracts xff0c; second deployment does not have two transactions xff0c; first-time library)

Error! Unable to generate Contract ByteCode and ABI (Expected library(ies) but one or more was not provided)

错误图

Error Diagram

在这里插入图片描述

 insert picture description here

提交页面加上library

Submit Page Plus Library

在这里插入图片描述

 insert the picture here

构造参数

构造参数填不填都可能可以提交成功, 比较迷,不了解区块浏览器提交时咋校验/以及要求的

Constructing parameters without filling may be able to submit success & #xff0c; obsessive & #xff0c; do not know how to verify/and request block browser submissions

构造参数有两种情况需要处理

There are two types of construction parameters that need to be addressed.

  1. 如果你确认上面所说的基本配置都选对了的情况下,还是提交了,错误就是常规的说byteCode不一样,这个时候可以尝试把构造参数填上
  2. 如果开源页面,构造参数自动给填了一堆东西,需要删掉提交, 删掉还是不成功,按照1的情况处理一遍

第二种情况缺图~~

The second one's missing.

第一种情况,就是指的byteCode不一样,没有额外提示

First case xff0c; byteCode different xff0c; no additional hint

Error! Unable to generate Contract ByteCode and ABI

在这里插入图片描述

 insert the picture description here

这里说下如何构建构造参数

Here's how to construct the construction parameters.

方式一

通过 https://abi.hashex.org/# 网站来生成
填入合约的ABI,点击Parse, 然后选择constructor, 生成的内容填到开源页面的构造参数里面

to generate
ABIxff0c from the contract; click on Parse, then select Constructor, generate content to fill in the construction parameters of the open source page

在这里插入图片描述

 insert picture description here

注:这个生成的,有时不能用,不能用的时候,查看方式二, 为啥不能用,不详,确实和实际的不一样
有可能是因为0.8.x的数组方式编码有所改变,或者其他,没有细究

Note xff1a; this generated xff0c; sometimes unable to use xff0c; xff0c; view mode IIxff0c; Why not xff0c; nxff0c; actual and actual differences
may be due to a change in the numeric coding of 0.8.x xff0c; or other xff0c; no elaboration

方式二

这个方式是无意中发现的,就是因为上面的方式一 编码的结果无法提交开源 最后把所有bytecode复制出来,查询某个参数时,发现bytecode里面有这个参数,然后有细微差别

This is an unintentional discovery of xff0c; the result of the code above cannot be submitted to the open source and then copies all bytecodes xff0c; xff0c when searching for a parameter; xff0c when found in bytecode; and xff0c; and nuanced.

以下是代码的相关参数

Here are the parameters of the code.

 

方式一生成的

It's generated by mode one.

方式二获取的

From Mode Two

合约地址
https://testnet.bscscan.com/address/0x502fD252c99Da72918532cDC5B8191477cBEFF45#code

Contract address
https://testnet.bsccan.com/address/0x502fD252c99Da72818532cDC5B81919477cBEF45#code

参数配置

Parameter Configuration

 

情况1 基本配置都正确,没有构造参数和library

在这里插入图片描述

 insert the picture here

情况2 补上library,不填构造参数

在这里插入图片描述

 insert the picture here

情况3 填写构造参数(一般可以通过,也可能无法通过)

对于这个代码,可能涉及数组或者是0.8.x动态数据构建有啥变化,原因不确定
内容如下,通过 https://abi.hashex.org 生成的

For this code xff0c; may relate to arrays or 0.8.x dynamic data construction xff0c; cause
is uncertain xff0c; generated by https://bi.hashex.org>

错误和情况2中的一模一样, 这里就不填图了

The error is exactly the same as in case 2. #xff0c; this is not the place to fill it out.

情况4 从浏览器提示中取构造参数

在这里插入图片描述

 insert picture description here

查看上图

View Up Chart

  1. 最右边的红色箭头,将滚动条拖动到最右边,然后双击上面内容,复制,(你也可以按住拖动复制到最右边)
  2. 将内容粘贴到文本框,在最后面找很多0开始的地方…

如我现在这个例子,第一参数是字符串,下面data第一个内容16,不确定是偏移量还是指的长度。
刚开源一个发现没有固定前缀, 如果第一个是地址类型,那么地址签名还会有24个0

As I am now in the case of xff0c; the first parameter is the string xff0c; the following data is in the first content 16xff0c; uncertainty is whether it is the length of the deviation or the length.
a new source finds no fixed prefix xff0c; if the first is the address type xff0c; then there are still 24 zero addresses.

所以,找很多0的地方,开始截取,就是构造参数

So #xff0c; looking for lots of zeros #xff0c; starting to intercept #xff0c; that's the construction parameters

注意:不要在页面直接双击,双击得到的不是完整内容,只是左边部分,右边还有两个{ipfs}开始的,双击不会带上, 得拖动到最右边
另外图上面看起来最右边还有两个0没有复制到,忽略,可能是浏览器显示问题

notes : do not double-click xff0c directly on the page; double-click xff0c; only left-hand xff0c; two more fffs} start xff0c on the right; double-click xff0c; drag to the rightmost
; and two zeros on the right seem not to copy xff0c; ignore xff0c; probably the browser display problem

得到的内容如下

Here's what I got.

可以对比通过hashex网址构建到的不一样

It's a comparison of what's built through the Hashex site.

以上就开源成功了
在这里插入图片描述


).

如果想开源library, 找到library的地址, 把基本配置填一样的, 代码还是用整个代码即可,提交就直接通过了

If you want to open the source library, find library's address & #xff0c; fill the basic configuration with the same xff0c; the code is still the whole code xff0c; the submission goes straight through

测试

test

如果你想测试这样开源,可以复制上面链接的代码,在代码中随便加个代码, 比如

If you want to test this open source xff0c; you can copy the code from the link xff0c; you can add any code to the code xff0c; for example

 

这样可以避免和已开源的一样,直接被开源了

This avoids the same open source as the open source #xff0c; it's opened directly.

这里补充一个以前在heco上面的坑
多文件部署的合约
开源的时候,选择上传多个文件, 怎么提交都不通过, 最后把文件合并成一个文件,给通过了…

Add a previously deployed multi-filed contract on Heco

& #xff0c > ; selects to upload multiple files & #xff0c ; files are not submitted through xff0c ; lastly, files are merged into a single document xff0c; adopted...

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 区块链社区有哪些?区块链社区是什么?

    区块链社区有哪些?区块链社区是什么?
    展开全文...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
  • 0.00015693个比特币等于多少人民币/美金

    0.00015693个比特币等于多少人民币/美金
    0.000 15693比特币等于多少人民币?根据比特币对人民币的最新汇率,0.000 15693比特币等于10.6 1678529美元/76.86554996人民币。比特币(BTC)【比特币价格翻倍】美元(USDT)人民币(CNY)0.000/克洛克-0/5693【数字货币矿机】10.6 167852976.8655254996比特币对人民币的最新汇率为:489,807.72 CNY(1比特币= 489,807.72人民币)(1美元=7.24人民币)(0.00015693 U...
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • 2018-5-31币圈简报

    2018-5-31币圈简报
    一、要闻资讯类I. KEY INFORMATION CATEGORY1、央视:数字货币在京揭牌成立!中国或为此突变!1. View: Digital currency is established in Kyoto! China or mutated for it!中国数字货币来了˂a href="https://mp.weixin.qq.com/s/69fxKCf8GKSCscS4lT8WCA" Target="_blank"rel="noformlow"" Chinese...
标签列表