当前位置:网站首页>Analysis of eip-2535 diamond agreement from the Saudi NFT event
Analysis of eip-2535 diamond agreement from the Saudi NFT event
2022-07-17 23:49:00 【Blockchain metauniverse chaingame NFT digital collection】
2022 year 7 month 10 Number , A fiery NFT project TheSaudis Open the freemint Activities ( White list users can cast their... For free NFT). And on mint After the event , A name RIGHTBLOCK Of users have sold this NFT, After finding out, the project party quickly locked in the user and made changes to the contract, so as to bring a large number of NFT Move it back , They later promised to take these NFT Give feedback to community users .

So why can the project party put the NFT What about the transfer ? After our analysis, we found that NFT The contract of the project adopts EIP-2535 The agreement is also called the diamond agreement , The project party used the agreement to rewrite the function of the contract , In order to achieve these NFT The transfer of . Next, the slow fog security team will introduce the diamond agreement (EIP-2535) The details of the .
Smart contract breakthrough 24kb The maximum size limit , And make it easier for the contract to update functions .
Understand the diamond agreement , First of all, there are several related concept definitions to know :
diamond (diamond): Diamonds can be understood as agency contracts (Proxy), It is also the main contract to interact with users
section (facet): Just as real diamonds have different sides , A diamond contract also has different aspects , Each function of diamond contract needs to call a contract corresponding to a section , So it can also be understood as realizing the contract (Implementation)
Diamond cutting (diamondCut): The diamond protocol standard extends a function called diamond cutting , Its main role increases from diamonds 、 Replace or delete facets and functions , It can be understood as the upgrade of the contract (Upgrade)
Magnifier (The Loupe): The magnifying glass function in the diamond protocol standard is mainly to return information about the section and the existence of diamonds , This information is stored inside the diamond contract ——DiamondStorage in
The whole diamond model is similar to the following figure :

Create diamond contracts by using diamond standard specifications , This contract can use any number of code of other faceted contracts just like the code of the current contract .
In this diamond contract, different functions need to call the corresponding codes of different facet contracts to realize , And the function of diamond cutting can be used to modify the function in the diamond contract ( add to 、 Replace or delete ).
This is different from the way most of the market use an agent contract and an implementation contract to realize interaction and upgrading .

This function will first call LibDiamond Library enforceIsContractOwner Function to determine whether the caller is contractual owner, If it is owner If called, it will call LibDiamond Library diamondCut Function to update the function of diamond contract .

Following up on this function, we found that diamond cutting will vary according to the incoming action To judge and add 、 Replace or delete functions , So next, follow up and see the transaction in which the project party calls this function .

We found that a new aspect contract was introduced 0x70d8ccaf6b50b051ab1e8fa238626163e45a8b03( Not open source ), Incoming action Set to 1 It should call replaceFunctions To implement the replacement function .

from replaceFunctions Function can be analyzed that this function will first add a new aspect for the incoming address , Then read the old section corresponding to each function selector passed in from the storage loop to delete , And add the facet of these functions as the incoming new facet address .
So far, we can know The Saudis The project party used the diamond cutting function to rewrite the transfer function , In this way, users RIGHTBLOCK Hand NFT Transfer back to your account .
边栏推荐
- Charles的基本使用及教程
- Unity judges whether the object is in front of the camera and the UI follows the 3D object
- Degree engine (12): video loading
- nVisual二次开发——第一章 入门介绍
- Go语言指针
- Wechat applet - Advanced chapter package JSON Version Description and detailed explanation of various version symbols (I)
- . Net full scene development has finally arrived
- 如何调试 C# Emit 生成的动态代码?
- Structure and design of kernel
- Pytest+request+allure+excel interface automatic construction from 0 to 1 [three package request]
猜你喜欢

Detailed explanation of pointer and array written test questions

How to debug the dynamic code generated by C emit?

Structure and design of kernel
![Serein [lazy artifact] a graphical tool that collects URLs in batches and detects the collected URLs in batches. It solves the problem of fishing project](/img/bb/92c0df77ff53e4918e491694ec97ff.png)
Serein [lazy artifact] a graphical tool that collects URLs in batches and detects the collected URLs in batches. It solves the problem of fishing project

Count the age distribution (interval statistics of 5 years old) and draw the age distribution map.

Js13day (function definition method, call, apply, bind change this point, strict mode, closure, recursion, shallow copy method, deep copy function encapsulation)

Dlvm netcore open source Framework

15.1.1 MySQL - date time function of MySQL, date format

【C语言入门】----指针(初阶)

Seven sorts (1)
随机推荐
Introduction to Kali system use of hping3
疑似被Apple招安,PlayCover作者删库跑路
dlvm-netcore 開源框架
区别go array,slice,map
Seven sorts (1)
LOCUST性能测试1(认识)
DEDECMS织梦更改include目录重命名后,后台属性编辑无法加载的解决方法
What is the structure of polardb for PostgreSQL combined with CEPH shared storage?
Keyword search Suning commodity API interface (Suning commodity list API interface)
Interface test - process test supports batch parameter import, and the test efficiency is directly full!
小红书商品详情API接口(item_get-获得小红书商品详情接口)
PLC approximately calculates the water tank flow (FC) through Bernoulli equation
关于DP中完全背包的遍历次序探讨
七大排序(一)
京东店铺所有商品API接口(JD整店商品查询API接口)
The most common algorithm interview questions
[security dog] Microsoft updated and solved multiple vulnerabilities in July
Sword finger offer 06 Print linked list from end to end
For 10 consecutive years, the "most commonly used" programming language for programmers ranked first is....
拼多多店铺所有商品API接口(整店商品列表查询接口)