You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contracts/multiwrap/multiwrap.md
+12-18Lines changed: 12 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,25 +10,19 @@ The document is written for technical and non-technical readers. To ask further
10
10
11
11
The thirdweb Multiwrap contract lets you wrap arbitrary ERC20, ERC721 and ERC1155 tokens you own into a single wrapped token / NFT.
12
12
13
-
The `Multiwrap` contract is meant to be used for bundling up multiple assets (ERC20 / ERC721 / ERC1155) into a single wrapped token, which can then
14
-
be unwrapped in exchange for the underlying tokens.
13
+
The `Multiwrap` contract is meant to be used for bundling up multiple assets (ERC20 / ERC721 / ERC1155) into a single wrapped token, which can then be unwrapped in exchange for the underlying tokens.
15
14
16
-
The single wrapped token received on bundling up multiple assets, as mentioned above, is an ERC721 NFT. It can be transferred, sold on any NFT Marketplace, and
17
-
generate royalties just like any other NFTs.
15
+
The single wrapped token received on bundling up multiple assets, as mentioned above, is an ERC721 NFT. It can be transferred, sold on any NFT Marketplace, and generate royalties just like any other NFTs.
18
16
19
17
### Why we’re building `Multiwrap`
20
18
21
-
We're building `Multiwrap` for cases where an application wishes to bundle up / distribute / transact over *n* independent tokens all at once, as a single asset. This opens
22
-
up several novel NFT use cases.
19
+
We're building `Multiwrap` for cases where an application wishes to bundle up / distribute / transact over *n* independent tokens all at once, as a single asset. This opens up several novel NFT use cases.
23
20
24
-
For example, consider a lending service where people can take out a loan while putting up an NFT as a collateral. Using `Multiwrap`, a borrower can wrap their NFT with
25
-
some ether, and put up the resultant wrapped ERC721 NFT as collateral on the lending service. Now, the bowwoer's NFT, as collateral, has a floor value.
21
+
For example, consider a lending service where people can take out a loan while putting up an NFT as a collateral. Using `Multiwrap`, a borrower can wrap their NFT with some ether, and put up the resultant wrapped ERC721 NFT as collateral on the lending service. Now, the borrower's NFT, as collateral, has a floor value.
26
22
27
23
## Technical Details
28
24
29
-
The `Multiwrap` contract itself is an ERC721 contract. It lets you wrap arbitrary ERC20, ERC721 and ERC1155 tokens you own into a single wrapped token / NFT. This means
30
-
escrowing the relevant ERC20, ERC721 and ERC1155 tokens into the `Multiwrap` contract, and receiving the wrapped NFT in exchange. This wrapped NFT can later be 'unwrapped'
31
-
i.e. burned in exchange for the underlying tokens.
25
+
The `Multiwrap` contract itself is an ERC721 contract. It lets you wrap arbitrary ERC20, ERC721 and ERC1155 tokens you own into a single wrapped token / NFT. This means escrowing the relevant ERC20, ERC721 and ERC1155 tokens into the `Multiwrap` contract, and receiving the wrapped NFT in exchange. This wrapped NFT can later be 'unwrapped' i.e. burned in exchange for the underlying tokens.
32
26
33
27
### Wrapping tokens
34
28
@@ -42,7 +36,7 @@ struct Token {
42
36
address assetContract;
43
37
TokenType tokenType;
44
38
uint256 tokenId;
45
-
uint256 amount;
39
+
uint256 totalAmount;
46
40
}
47
41
```
48
42
@@ -51,23 +45,23 @@ struct Token {
51
45
| assetContract | address | The contract address of the asset to wrap. |
52
46
| tokenType | TokenType | The token type (ERC20 / ERC721 / ERC1155) of the asset to wrap. |
53
47
| tokenId | uint256 | The token Id of the asset to wrap, if the asset is an ERC721 / ERC1155 NFT. |
54
-
|amount| uint256 | The amount of the asset to wrap, if the asset is an ERC20 / ERC1155 fungible token. |
48
+
|totalAmount| uint256 | The amount of the asset to wrap, if the asset is an ERC20 / ERC1155 fungible token. |
55
49
56
-
Each token in the bundle of tokens to be wrapped as a single wrapped NFT must be specified to the `Multiwrap` contract in the form of the `Token` struct. The contract handles the respective token based on the value of `tokenType` provided. Any incorrect values passed (e.g. the `amount` specified to be wrapped exceeds the token owner's token balance) will cause the wrapping transaction to revert.
50
+
Each token in the bundle of tokens to be wrapped as a single wrapped NFT must be specified to the `Multiwrap` contract in the form of the `Token` struct. The contract handles the respective token based on the value of `tokenType` provided. Any incorrect values passed (e.g. the `totalAmount` specified to be wrapped exceeds the token owner's token balance) will cause the wrapping transaction to revert.
57
51
58
52
Multiple tokens can be wrapped as a single wrapped NFT by calling the following function:
59
53
60
54
```solidity
61
55
function wrap(
62
-
Token[] memory wrappedContents,
56
+
Token[] memory tokensToWrap,
63
57
string calldata uriForWrappedToken,
64
58
address recipient
65
59
) external payable returns (uint256 tokenId);
66
60
```
67
61
68
62
| Parameters | Type | Description |
69
63
| --- | --- | --- |
70
-
|wrappedContents| Token[]| The tokens to wrap. |
64
+
|tokensToWrap| Token[]| The tokens to wrap. |
71
65
| uriForWrappedToken | string | The metadata URI for the wrapped NFT. |
72
66
| recipient | address | The recipient of the wrapped NFT. |
73
67
@@ -86,8 +80,8 @@ function unwrap(
86
80
87
81
| Parameters | Type | Description |
88
82
| --- | --- | --- |
89
-
| tokenId | Token[]| The token Id of the wrapped NFT to unwrap..|
90
-
| recipient | address | The recipient of the underlying ERC1155, ERC721, ERC20 tokens of the wrapped NFT. |
83
+
| tokenId | Token[]| The token Id of the wrapped NFT to unwrap. |
84
+
| recipient | address | The recipient of the underlying ERC20, ERC721 or ERC1155 tokens of the wrapped NFT. |
91
85
92
86
When unwrapping the single wrapped NFT, the wrapped NFT is burned.
0 commit comments