## OpenSea ERC-1155 Starter Contracts
- [About these contracts](#about-these-contracts)
- [Configuring the Lootbox](#configuring-the-lootbox)
- [Why are some standard methods overridden?](#why-are-some-standard-methods-overridden)
- [Requirements](#requirements)
- [Node version](#node-version)
- [Installation](#installation)
- [Deploying](#deploying)
- [Deploying to the Rinkeby network.](#deploying-to-the-rinkeby-network)
- [Deploying to the mainnet Ethereum network.](#deploying-to-the-mainnet-ethereum-network)
- [Viewing your items on OpenSea](#viewing-your-items-on-opensea)
- [Troubleshooting](#troubleshooting)
- [It doesn't compile!](#it-doesnt-compile)
- [It doesn't deploy anything!](#it-doesnt-deploy-anything)
- [Minting tokens.](#minting-tokens)
- [License](#license)
- [ERC1155 Implementation](#erc1155-implementation)
# About these contracts
This is a sample ERC-1155 contract for the purposes of demonstrating integration with the [OpenSea](https://opensea.io) marketplace for crypto collectibles. We also include:
- A script for minting items.
- A factory contract for making sell orders for unminted items (allowing for **gas-free and mint-free presales**).
- A configurable lootbox contract for selling randomized collections of ERC-1155 items.
On top of the features from the [OpenSea ERC721 sample contracts](https://github.com/ProjectOpenSea/opensea-creatures), ERC1155
- supports multiple creators per contract, where only the creator is able to mint more copies
- supports pre-minted items for the lootbox to choose from
## Configuring the Lootbox
Open MyLootbox.sol
1. Change `Class` to reflect your rarity levels.
2. Change `NUM_CLASSES` to reflect how many classes you have (this gets used for sizing fixed-length arrays in Solidity)
3. In `constructor`, set the `OptionSettings` for each of your classes. To do this, as in the example, call `setOptionSettings` with
1. Your option id,
2. The number of items to issue when the box is opened,
3. An array of probabilities (basis points, so integers out of 10,000) of receiving each class. Should add up to 10k and be descending in value.
4. Then follow the instructions below to deploy it! Purchases will auto-open the box. If you'd like to make lootboxes tradable by users (without a purchase auto-opening it), contact us at contact@opensea.io (or better yet, in [Discord](https://discord.gg/ga8EJbv)).
## Why are some standard methods overridden?
This contract overrides the `isApprovedForAll` method in order to whitelist the proxy accounts of OpenSea users. This means that they are automatically able to trade your ERC-1155 items on OpenSea (without having to pay gas for an additional approval). On OpenSea, each user has a "proxy" account that they control, and is ultimately called by the exchange contracts to trade their items.
Note that this addition does not mean that OpenSea itself has access to the items, simply that the users can list them more easily if they wish to do so!
# Requirements
### Node version
Either make sure you're running a version of node compliant with the `engines` requirement in `package.json`, or install Node Version Manager [`nvm`](https://github.com/creationix/nvm) and run `nvm use` to use the correct version of node.
## Installation
Run
```bash
yarn
```
## Deploying
### Deploying to the Rinkeby network.
1. You'll need to sign up for [Infura](https://infura.io). and get an API key.
2. You'll need Rinkeby ether to pay for the gas to deploy your contract. Visit https://faucet.rinkeby.io/ to get some.
3. Using your API key and the mnemonic for your MetaMask wallet (make sure you're using a MetaMask seed phrase that you're comfortable using for testing purposes), run:
```
export INFURA_KEY="<infura_key>"
export MNEMONIC="<metmask_mnemonic>"
truffle migrate --network rinkeby
```
### Deploying to the mainnet Ethereum network.
Make sure your wallet has at least a few dollars worth of ETH in it. Then run:
```
yarn truffle migrate --network live
```
Look for your newly deployed contract address in the logs! �コ
### Viewing your items on OpenSea
OpenSea will automatically pick up transfers on your contract. You can visit an asset by going to `https://opensea.io/assets/CONTRACT_ADDRESS/TOKEN_ID`.
To load all your metadata on your items at once, visit [https://opensea.io/get-listed](https://opensea.io/get-listed) and enter your address to load the metadata into OpenSea! You can even do this for the Rinkeby test network if you deployed there, by going to [https://rinkeby.opensea.io/get-listed](https://rinkeby.opensea.io/get-listed).
### Troubleshooting
#### It doesn't compile!
Install truffle locally: `yarn add truffle`. Then run `yarn truffle migrate ...`.
You can also debug just the compile step by running `yarn truffle compile`.
#### It doesn't deploy anything!
This is often due to the truffle-hdwallet provider not being able to connect. Go to infura.io and create a new Infura project. Use your "project ID" as your new `INFURA_KEY` and make sure you export that command-line variable above.
### Minting tokens.
After deploying to the Rinkeby network, there will be a contract on Rinkeby that will be viewable on [Rinkeby Etherscan](https://rinkeby.etherscan.io). For example, here is a [recently deployed contract](https://rinkeby.etherscan.io/address/0xeba05c5521a3b81e23d15ae9b2d07524bc453561). You should set this contract address and the address of your Metamask account as environment variables when running the minting script:
```
export OWNER_ADDRESS="<my_address>"
export FACTORY_CONTRACT_ADDRESS="<deployed_contract_address>"
export NETWORK="rinkeby"
node scripts/advanced/mint.js
```
Note: When running the minting script on mainnet, your environment variable needs to be set to `mainnet` not `live`. The environment variable affects the Infura URL in the minting script, not truffle. When you deploy, you're using truffle and you need to give truffle an argument that corresponds to the naming in truffle.js (`--network live`). But when you mint, you're relying on the environment variable you set to build the URL (https://github.com/ProjectOpenSea/opensea-creatures/blob/master/scripts/mint.js#L54), so you need to use the term that makes Infura happy (`mainnet`). Truffle and Infura use the same terminology for Rinkeby, but different terminology for mainnet. If you start your minting script, but nothing happens, double check your environment variables.
# License
These contracts are available to the public under an MIT License.
### ERC1155 Implementation
To implement the ERC1155 standard, these contracts use the Multi Token Standard by [Horizon Games](https://horizongames.net/), available on [npm](https://www.npmjs.com/package/multi-token-standard) and [github](https://github.com/arcadeum/multi-token-standard) and also under the MIT License.
没有合适的资源?快使用搜索试试~ 我知道了~
1155tokentime:创建ERC1155教程
共59个文件
png:23个
js:11个
sol:11个
需积分: 50 4 下载量 48 浏览量
2021-03-28
05:49:15
上传
评论
收藏 2.05MB ZIP 举报
温馨提示
OpenSea ERC-1155入门合同 关于这些合同 这是一份ERC-1155合同样本,目的是演示与加密收藏品市场的集成。 我们还包括: 铸造物品的脚本。 一份工厂合同,用于制作未铸造物品的销售订单(允许无气和无薄荷的预售)。 可配置的战利品合同,用于出售ERC-1155项目的随机集合。 除了,ERC1155 每个合同支持多个创建者,其中只有创建者才能创建更多副本 支持战利品箱中预先铸造的物品供您选择 配置战利品箱 打开MyLootbox.sol 更改Class以反映您的稀有程度。 更改NUM_CLASSES以反映您拥有多少个类(用于在NUM_CLASSES中调整固定长度数组的大小) 在constructor ,为每个类设置OptionSettings 。 为此,如示例中所示,使用以下命令调用setOptionSettings 您的选项ID, 打开包装盒时要发出的物品
资源详情
资源评论
资源推荐
收起资源包目录
1155tokentime-master.zip (59个子文件)
1155tokentime-master
.nvmrc 6B
package.json 1KB
test
MyCollectible.js 638B
ERC1155Tradable.js 13KB
MyFactory.js 13KB
MyLootBox.js 8KB
flatten.sh 272B
metadata-api
app.py 6KB
images
mouths
mouth-cute.png 3KB
mouth-pleased.png 3KB
mouth-smirk.png 3KB
mouth-surprised.png 3KB
mouth-happy.png 3KB
factory
egg.png 130KB
four-eggs.png 270KB
output
1.png 135KB
7.png 111KB
temp.txt 0B
3.png 84KB
bases
base-jellyfish.png 94KB
base-goldfish.png 162KB
base-crab.png 94KB
base-starfish.png 120KB
base-narwhal.png 162KB
base-tealfish.png 141KB
eyes
eyes-sleepy.png 3KB
eyes-wink.png 9KB
eyes-joy.png 12KB
eyes-content.png 3KB
eyes-big.png 9KB
box
lootbox.png 163KB
multiple-eggs.png 209KB
Procfile 35B
src
pip-delete-this-directory.txt 185B
requirements.txt 1KB
.gitignore 31B
LICENSE 1KB
.env.sample 220B
migrations
2_deploy_contracts.js 2KB
1_initial_migration.js 231B
contracts
SafeMath.sol 4KB
IFactory.sol 2KB
MyCollectible.sol 550B
test
TestForReentrancyAttack.sol 3KB
MockProxyRegistry.sol 769B
MyFactory.sol 5KB
Migrations.sol 515B
MyLootBox.sol 12KB
Strings.sol 2KB
ILootBox.sol 3KB
ERC1155Tradable.sol 6KB
.gitignore 96B
lib
testValuesCommon.js 406B
README.md 7KB
yarn.lock 427KB
scripts
advanced
mint.js 2KB
sell.js 4KB
initial_sale.js 3KB
truffle-config.js 3KB
共 59 条
- 1
小林家的珂女仆
- 粉丝: 32
- 资源: 4656
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于C#和ASP.NET Core的智能家居管理系统.zip
- (源码)基于rosserial的STM32嵌入式ROS通信系统库(Yoneken版改进版).zip
- 9.4 使用生成的识别器模型faceModel.xml预测新图像,并输出匹配结果标签和置信度
- (源码)基于Spring Boot和Shiro的电商管理系统.zip
- (源码)基于Arduino和Blinker的智能时钟控制系统.zip
- (源码)基于C++编程语言的WyoOS操作系统.zip
- 9.3 使用EigenFaceRecognizer训练人脸分类器,并将模型保存为faceModel.xml文件
- (源码)基于Spring Boot 2的管理后台系统.zip
- (源码)基于Java Swing的铁路售票系统.zip
- (源码)基于Java的电源租赁管理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0