|
| 1 | +<a id="contracts.multiwrap"></a> |
| 2 | + |
| 3 | +# contracts.multiwrap |
| 4 | + |
| 5 | +<a id="contracts.multiwrap.Multiwrap"></a> |
| 6 | + |
| 7 | +## Multiwrap Objects |
| 8 | + |
| 9 | +```python |
| 10 | +class Multiwrap(ERC721[MultiwrapABI]) |
| 11 | +``` |
| 12 | + |
| 13 | +Multiwrap lets you wrap any number of ERC20, ERC721, or ERC1155 tokens into |
| 14 | +a single wrapped token bundle. |
| 15 | + |
| 16 | +```python |
| 17 | +from thirdweb import ThirdwebSDK |
| 18 | + |
| 19 | +# You can customize this to a supported network or your own RPC URL |
| 20 | +network = "mumbai" |
| 21 | + |
| 22 | +# Now we can create a new instance of the SDK |
| 23 | +sdk = ThirdwebSDK(network) |
| 24 | + |
| 25 | +# If you want to send transactions, you can instantiate the SDK with a private key instead: |
| 26 | +# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network) |
| 27 | + |
| 28 | +contract = sdk.get_multiwrap("{{contract_address}}") |
| 29 | +``` |
| 30 | + |
| 31 | +<a id="contracts.multiwrap.Multiwrap.get_wrapped_contents"></a> |
| 32 | + |
| 33 | +#### get\_wrapped\_contents |
| 34 | + |
| 35 | +```python |
| 36 | +def get_wrapped_contents(wrapped_token_id: int) -> WrappedTokens |
| 37 | +``` |
| 38 | + |
| 39 | +Get the contents of a wrapped token bundle |
| 40 | + |
| 41 | +**Arguments**: |
| 42 | + |
| 43 | +- `wrapped_token_id`: The ID of the wrapped token to get the contents of |
| 44 | + |
| 45 | +**Returns**: |
| 46 | + |
| 47 | +The contents of the wrapped token bundle |
| 48 | +```python |
| 49 | +token_id = 0 |
| 50 | +contents = contract.get_wrapped_contents(token_id) |
| 51 | +print(contents.erc20_tokens) |
| 52 | +print(contents.erc721_tokens) |
| 53 | +print(contents.erc1155_tokens) |
| 54 | +``` |
| 55 | + |
| 56 | +<a id="contracts.multiwrap.Multiwrap.wrap"></a> |
| 57 | + |
| 58 | +#### wrap |
| 59 | + |
| 60 | +```python |
| 61 | +def wrap( |
| 62 | + contents: TokensToWrap, |
| 63 | + wrapped_token_metadata: Union[str, NFTMetadataInput], |
| 64 | + recipient_address: Optional[str] = None |
| 65 | +) -> TxResultWithId[NFTMetadataOwner] |
| 66 | +``` |
| 67 | + |
| 68 | +Wrap any number of ERC20, ERC721, or ERC1155 tokens into a single wrapped token |
| 69 | + |
| 70 | +**Arguments**: |
| 71 | + |
| 72 | +- `contents`: The tokens to wrap into a single wrapped token |
| 73 | +- `wrapped_token_metadata`: The metadata to use for the wrapped token |
| 74 | +- `recipient_address`: The optional address to send the wrapped token to |
| 75 | + |
| 76 | +**Returns**: |
| 77 | + |
| 78 | +The transaction receipt of the token wrapping |
| 79 | +```python |
| 80 | +from thirdweb.types import ( |
| 81 | + TokensToWrap, |
| 82 | + ERC20Wrappable, |
| 83 | + ERC721Wrappable, |
| 84 | + ERC1155Wrappable, |
| 85 | + NFTMetadataInput, |
| 86 | +) |
| 87 | + |
| 88 | +# Contract setup goes here... |
| 89 | + |
| 90 | +tx = contract.wrap( |
| 91 | + TokensToWrap( |
| 92 | + erc20_tokens=[ |
| 93 | + ERC20Wrappable(contract_address="0x...", quantity=0.8), |
| 94 | + ], |
| 95 | + erc721_tokens=[ |
| 96 | + ERC721Wrappable(contract_address="0x...", token_id=0), |
| 97 | + ], |
| 98 | + erc1155_tokens=[ |
| 99 | + ERC1155Wrappable(contract_address="0x...", token_id=0, quantity=1), |
| 100 | + ] |
| 101 | + ), |
| 102 | + NFTMetadataInput( |
| 103 | + name="Wrapped NFT", |
| 104 | + description="This is a wrapped bundle of tokens and NFTs", |
| 105 | + image="ipfs://...", |
| 106 | + ) |
| 107 | +) |
| 108 | + |
| 109 | +print(tx.receipt, tx.id) |
| 110 | +``` |
| 111 | + |
| 112 | +<a id="contracts.multiwrap.Multiwrap.unwrap"></a> |
| 113 | + |
| 114 | +#### unwrap |
| 115 | + |
| 116 | +```python |
| 117 | +def unwrap(wrapped_token_id: int, |
| 118 | + recipient_address: Optional[str] = None) -> TxReceipt |
| 119 | +``` |
| 120 | + |
| 121 | +Unwrap a wrapped token bundle |
| 122 | + |
| 123 | +**Arguments**: |
| 124 | + |
| 125 | +- `wrapped_token_id`: The ID of the wrapped token to unwrap |
| 126 | +- `recipient_address`: The optional address to send the unwrapped tokens to |
| 127 | + |
| 128 | +**Returns**: |
| 129 | + |
| 130 | +The transaction receipt of the token unwrapping |
| 131 | +```python |
| 132 | +tx = contract.unwrap(wrapped_token_id, receipientAddress) |
| 133 | +``` |
| 134 | + |
0 commit comments