Coder Social home page Coder Social logo

projectopensea / opensea-erc1155 Goto Github PK

View Code? Open in Web Editor NEW
607.0 25.0 289.0 2.51 MB

Example semi-fungible collectible, to demonstrate OpenSea integration for an ERC-1155 contract

Home Page: https://docs.opensea.io

License: MIT License

Shell 0.29% Python 6.27% JavaScript 52.51% Solidity 40.90% Procfile 0.04%

opensea-erc1155's Introduction

OpenSea ERC-1155 Starter Contracts

About these contracts

This is a sample ERC-1155 contract for the purposes of demonstrating integration with the OpenSea 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, 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 [email protected].

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 and run nvm use to use the correct version of node.

Installation

Run

yarn

Deploying

Deploying to the Rinkeby network.

  1. You'll need to sign up for Infura. 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 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.

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. For example, here is a recently deployed contract. 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, available on npm and github and also under the MIT License.

opensea-erc1155's People

Contributors

alexanderatallah avatar cybourgeoisie avatar dfinzer avatar erikaugust avatar jmac-opensea avatar wombatlabs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opensea-erc1155's Issues

Collection deleted and unable to create

Its giving me error:

We couldn't find this contract. Please ensure that this is a valid ERC721 or ERC1155 contract deployed on Rinkeby and that you have already minted items on the contract.

However the contract has items and was previously created!

Unable to get nft metadata

I created an ERC1155 NFT in opensea (TokenId: 51249058730426330109459860678910738092081333487213352264711093009751725834250), but it seems it can't get to metadaata.

The call to contracturi returns

https://api.opensea.io/api/v2/metadata/matic/0x2953399124F0cBB46d2CbACD8A89cF0599974963/0x{id}

According to the ERC1155 specification . I convert the tokenid to hex and replace it and get

https://api.opensea.io/api/v2/metadata/matic/0x2953399124F0cBB46d2CbACD8A89cF0599974963/0x714df076992f95e452a345cd8289882cec6ab82f000000000000000001000000000a

image

Always get success: false

truffle migrate --network rinkeby returns "MyLootBox" -- The contract code couldn't be stored, please check your gas limit

~/Development/opensea-erc1155(master):0 truffle migrate --network rinkeby

Compiling your contracts...
===========================
โœ” Fetching solc version list from solc-bin. Attempt #1
โœ” Downloading compiler. Attempt #1.
> Compiling ./contracts/ERC1155Tradable.sol
> Compiling ./contracts/IFactory.sol
> Compiling ./contracts/ILootBox.sol
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/MyCollectible.sol
> Compiling ./contracts/MyFactory.sol
> Compiling ./contracts/MyLootBox.sol
> Compiling ./contracts/SafeMath.sol
> Compiling ./contracts/Strings.sol
> Compiling ./contracts/test/MockProxyRegistry.sol
> Compiling ./contracts/test/TestForReentrancyAttack.sol
> Compiling multi-token-standard/contracts/interfaces/IERC1155.sol
> Compiling multi-token-standard/contracts/interfaces/IERC1155TokenReceiver.sol
> Compiling multi-token-standard/contracts/interfaces/IERC165.sol
> Compiling multi-token-standard/contracts/tokens/ERC1155/ERC1155.sol
> Compiling multi-token-standard/contracts/tokens/ERC1155/ERC1155Metadata.sol
> Compiling multi-token-standard/contracts/tokens/ERC1155/ERC1155MintBurn.sol
> Compiling multi-token-standard/contracts/utils/Address.sol
> Compiling multi-token-standard/contracts/utils/SafeMath.sol
> Compiling openzeppelin-solidity/contracts/GSN/Context.sol
> Compiling openzeppelin-solidity/contracts/access/Roles.sol
> Compiling openzeppelin-solidity/contracts/access/roles/PauserRole.sol
> Compiling openzeppelin-solidity/contracts/lifecycle/Pausable.sol
> Compiling openzeppelin-solidity/contracts/ownership/Ownable.sol
> Compiling openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol
> Compilation warnings encountered:

    /Users/$/Development/opensea-erc1155/contracts/MyCollectible.sol:19:3: Warning: Function state mutability can be restricted to pure
  function contractURI() public view returns (string memory) {
  ^ (Relevant source part starts here and spans across multiple lines).

> Artifacts written to /Users/$/Development/opensea-erc1155/build/contracts
> Compiled successfully using:
   - solc: 0.5.12+commit.7709ece9.Emscripten.clang



Migrations dry-run (simulation)
===============================
> Network name:    'rinkeby-fork'
> Network id:      4
> Block gas limit: 10000000 (0x989680)


1_initial_migration.js
======================
Using network: rinkeby-fork
Using accounts [
  '0x572CA7790260415b71C4de19f02c9F2311Baa909',
  '0xAd70c031647333F91172e9a728E0AEa342d9d4ea',
  '0x46c127f0C9f7f50b5EBA10207052630EdB16982c',
  '0xD27D913CCdbe5B5d441F42725A2FCf6af03C97Cd',
  '0x831743C3Bd5890cfF288755e7B01c6c540D2e532',
  '0xe46a6e2Ee673dd1A2BEF86a60aD701B419E60458',
  '0x0D3BC212aB5019eDB1Adc8697d52d5Bd74164f43',
  '0x9983EdcAF3ECc076aE0fD72c1626aB8C8a43da29',
  '0x9213DAe4FdBD42C22F9F667ab228A68018FdFf67',
  '0xD8e08eD50862a135CE955c814D0181184B51fe5B'
]

   Deploying 'Migrations'
   ----------------------
   > block number:        8156642
   > block timestamp:     1614579193
   > account:             0x16811935C8b4DEda61c2A9dd20dB8eD7253729d5
   > balance:             3.830943566
   > gas used:            210225 (0x33531)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.00042045 ETH

   -------------------------------------
   > Total cost:          0.00042045 ETH


2_deploy_contracts.js
=====================

   Deploying 'MyCollectible'
   -------------------------
   > block number:        8156644
   > block timestamp:     1614579202
   > account:             0x16811935C8b4DEda61c2A9dd20dB8eD7253729d5
   > balance:             3.823865964
   > gas used:            3511438 (0x35948e)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.007022876 ETH


   Deploying 'MyLootBox'
   ---------------------
   > block number:        8156645
   > block timestamp:     1614579219
   > account:             0x16811935C8b4DEda61c2A9dd20dB8eD7253729d5
   > balance:             3.816570698
   > gas used:            3647633 (0x37a891)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.007295266 ETH

   -------------------------------------
   > Total cost:         0.014318142 ETH


Summary
=======
> Total deployments:   3
> Final cost:          0.014738592 ETH





Starting migrations...
======================
> Network name:    'rinkeby'
> Network id:      4
> Block gas limit: 10000000 (0x989680)


1_initial_migration.js
======================
Using network: rinkeby
Using accounts [ '0x16811935C8b4DEda61c2A9dd20dB8eD7253729d5' ]

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0x0f27f134d37d52ca8d84035fbb204352a2db144c9844d07ad6dc7d095bd8fa66
   > Blocks: 1            Seconds: 16
   > contract address:    0x6B22B2784e61B502e12a4B4f1E9a3bF2A3e3Cf1a
   > block number:        8156644
   > block timestamp:     1614579246
   > account:             0x16811935C8b4DEda61c2A9dd20dB8eD7253729d5
   > balance:             3.826859516
   > gas used:            225225 (0x36fc9)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.0045045 ETH


   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:           0.0045045 ETH


2_deploy_contracts.js
=====================

   Deploying 'MyCollectible'
   -------------------------
   > transaction hash:    0xbeecc82102f0ca6e25ffa70758756b761bf0517f6dc6e6c052aefbb19ca66a38
   > Blocks: 0            Seconds: 12
   > contract address:    0xFCffE304633fEC42dFCf34C6744cdEA3cF7aa234
   > block number:        8156646
   > block timestamp:     1614579276
   > account:             0x16811935C8b4DEda61c2A9dd20dB8eD7253729d5
   > balance:             3.753683736
   > gas used:            3616426 (0x372eaa)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.07232852 ETH


   Deploying 'MyLootBox'
   ---------------------
   > transaction hash:    0xa8ff7c6adea7b60f86efe01d502223abfa1f0d532e5389c0d59ea4f73723040b


Error:  *** Deployment Failed ***

"MyLootBox" -- The contract code couldn't be stored, please check your gas limit..

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:68:1)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:55:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:171:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:87:1)
    at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:269:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:229:1
Truffle v5.1.39 (core: 5.1.39)
Node v12.18.0

get-listed not working on Rinkeby

Some weeks ago I was able to call get-listed from UI / Rinkeby for our own contracts.
Currently this is not working anymore.

I deployed MyCollectibles contract on Rinkeby and head over to the URL linked below.
https://rinkeby.etherscan.io/address/0xc3ed0a3f7936725a401e6E53A3E873e4aB6C9C42
Contract is verified, and one token minted (using "create()")

The UI returns : "We couldn't find this contract. Please ensure that this is a valid ERC721 or ERC1155 contract deployed on Rinkeby and that you have already minted items on the contract."

To load all your metadata on your items at once, visit 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.

Is this a temporary isue? Or is listing disabled for any reasons?

Thx for feedback!

Cannot find "mintTo" function

I tried to run script (mints.js) but I cannot find mintTo in ERC1155 smart contract.

What 's FACTORY_CONTRACT and NFT_CONTRACT in ERC1155 ?

 const result = await nftContract.methods.mintTo(OWNER_ADDRESS).send({ from: OWNER_ADDRESS });
            console.log("Minted creature. Transaction: " + result.transactionHash)

Can't see Lootbox on my openSea test network

after running truffle migrate --network rinkeby i got this log on console:

Starting migrations...

Network name: 'rinkeby'
Network id: 4
Block gas limit: 10000000 (0x989680)

2_deploy_contracts.js

Deploying 'CreatureAccessory'

transaction hash: 0xb713c9d11e82333d4c7eca64869c385746f670ada6ce416ba742cd6e98cabb62
Blocks: 1 Seconds: 13
contract address: 0x26C7761B64AF692A43BAe519bC80454cF7F5622D
block number: 8818395
block timestamp: 1624512412
account: 0x6358522e789C5a07e4D8C7F606f88ae4d1e5425F
balance: 26.180890536
gas used: 2802499 (0x2ac343)
gas price: 20 gwei
value sent: 0 ETH
total cost: 0.05604998 ETH

Deploying 'LootBoxRandomness'

transaction hash: 0x77c3ebd8f65cdb041f60222452334fcabec3c18e897f7c60e24484eaa11851c1
Blocks: 0 Seconds: 5
contract address: 0x86d7EB33B11cf5Ca177EeD1Af57687db776Cff1B
block number: 8818402
block timestamp: 1624512517
account: 0x6358522e789C5a07e4D8C7F606f88ae4d1e5425F
balance: 26.160201376
gas used: 454684 (0x6f01c)
gas price: 20 gwei
value sent: 0 ETH
total cost: 0.00909368 ETH

Linking

  • Contract: CreatureAccessoryLootBox <--> Library: LootBoxRandomness (at address: 0x86d7EB33B11cf5Ca177EeD1Af57687db776Cff1B)

Deploying 'CreatureAccessoryLootBox'

transaction hash: 0xefc068b81d0730bc00debda91d944388f16c9b5c940b42511ea38a18bd614214
Blocks: 0 Seconds: 5
contract address: 0x32a7beB30e2D6EE0d7b9b8309E8F27B7d8DBe735
block number: 8818403
block timestamp: 1624512532
account: 0x6358522e789C5a07e4D8C7F606f88ae4d1e5425F
balance: 26.084297316
gas used: 3795203 (0x39e903)
gas price: 20 gwei
value sent: 0 ETH
total cost: 0.07590406 ETH

Deploying 'CreatureAccessoryFactory'

transaction hash: 0x2b54ab8b5fd8b32ffe44cdd014230c3242b118bbf8afb9c01ddaef25e8090daf
Blocks: 2 Seconds: 17
contract address: 0xEE4E3cAfb341B854A6b17924A2B55A1607e7B947
block number: 8818405
block timestamp: 1624512562
account: 0x6358522e789C5a07e4D8C7F606f88ae4d1e5425F
balance: 26.061947536
gas used: 1117489 (0x110d31)
gas price: 20 gwei
value sent: 0 ETH
total cost: 0.02234978 ETH

Saving migration to chain.
Saving artifacts


Total cost: 0.1633975 ETH

Summary

Total deployments: 4
Final cost: 0.1633975 ETH

Done in 4

but i'm not able to see any lootbox on my openSea test network what could be the reason for it?

What is the purpose of having MyFactory.sol?

As I understood everything corretly, the final NFT contract is called MyCollectible.

But this example contains also a contract called MyFactory.sol which seems to be something like a Proxy as it also provides functions like balanceOf and safeTransferFrom, which are delegated to the MyCollectible-implementation.
What is the purpose of this class? Can we get some more documentation about this pls? Has it something to do with OpenSea-compatibility?

Thanks everybody in advance for any explanation!

Does OpenSea.io support ERC-1155 (Fungible Token)?

OpenSea.io says it is a marketplace for NFTs(Non-Fungible Token), and it also mentions ERC-1155, as we know, ERC-1155 supports NFT(Non-Fungible Token) and FT(Fungible Token), so, does OpenSea.io support ERC-1155 FT(Fungible Token)?

Support with safeTransferFrom()

Hi, I'm doing a job to load opensea collections and their tokens into another project and sell them with user approval.

The thing is that I have created a token in Rinkeby, and from my script, I setApprovalForAll() with my address to an address X to the OpenSea contract that I have in the token and it runs without problems.
The problem is when I want to transfer that token from the approved address. Calling safeTransferFrom()... I get

Fail with error 'AssetContractShared#_requireMintable: ONLY_CREATOR_ALLOWED'.

I've been reading around, and some say it's because you have to mine the token from the owner first...but I've tried that too, and I get this message:

Fail with error 'AssetContractShared#_requireMintable: SUPPLY_EXCEEDED'.

Any suggestions?

thanks

Allow non-cached NFTs on OpenSea

Sorry if this is the wrong place to suggest this, figured this is the easiest way to get an opensea engineer to suggest the feature to the business.


I'm currently working on an NFT that is frequently updated (as short as every minute). With opensea's caching and throttling, this means that the underlying NFT is not always reflected accurately on opensea. Even using GET /api/v1/asset/.../.../?force_update=True theres a few minutes of latency before cached images show up on opensea.


Suggestion:

Allow cache: false in the metadata, and opensea serves the image directly from the image: ipfs://<ipfs_cid> field

Error: Callback was already called.

cloning this repo and just trying to deploy straight up per the instructions throws this error:

hook@cryptodev:/opt/asdf/delme/opensea-erc1155$ yarn truffle migrate --network rinkeby
yarn run v1.22.10
$ /opt/asdf/delme/opensea-erc1155/node_modules/.bin/truffle migrate --network rinkeby

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



/opt/asdf/delme/opensea-erc1155/node_modules/truffle/build/webpack:/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:358
                callback(err);
^
Error: Callback was already called.
    at /opt/asdf/delme/opensea-erc1155/node_modules/truffle/build/webpack:/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:43:1
    at WriteStream.<anonymous> (/opt/asdf/delme/opensea-erc1155/node_modules/truffle/build/webpack:/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:358:1)
    at WriteStream.emit (events.js:315:20)
    at WriteStream.destroy (/opt/asdf/delme/opensea-erc1155/node_modules/truffle/build/webpack:/node_modules/level-ws/level-ws.js:140:1)
    at finish (internal/streams/writable.js:670:14)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

ask question

I want to trade nft on the opensea platform like superrare, but I have a question about how the royalties set on the superrare platform work

What actually it costs when deploying ERC1155 contracts onto mainnet.

I saw one sentence in README.md said:

"Deploying to the mainnet Ethereum network.
Make sure your wallet has at least a few dollars worth of ETH in it. Then run:"

I understand that this README.md is committed 16 month ago when the gas fee and ETH price is way lower than today, but I can't imagine that the price is ridiculously high (or am I making mistakes?).

Following is what I experience several hours ago.

Background: I already deployed & minted & tested all of my NFT in ERC1155 on rinkeby. Now I want to deploy then onto mainnet.
So I executed:

truffle migrate --network live

Then the script compile and deployed 2 contracts:
"1_initial_migration.js" -> "Migration.sol"
"2_deploy_contracts.js" -> "MyCollectible.sol"

After deploying "Migration.sol", the console warns that my wallet is out of balance to provide more gas for step two.
I review the log, and found the calculation of gas is like this:

Deploying 'Migrations'

gas used: 226537 (0x374e9)
gas price: 44.153401637 gwei
value sent: 0 ETH
total cost: 0.010002379146641069 ETH

This means the migration contract already cost me almost $25 USD to deploy the first part.

Reviewing the rest part of "MyCollectible", it is estimated to use 74***** gas which means another 0.33ETH for deploy the contract?

That is a HUGE cost !!!!

So please

  1. Anyone firstly review my operations to check if I wasted gas on unnecessary / incorrect operations.
  2. If I didn't do anything wrong, how can I recover the deployment process after storing enough ETH in my wallet? e.g. to avoid deploying "Migrations" other than simply executing truffle migrate --network live again.

Reentrancy in mint()

id = nftContract.create(_toAddress, _amount, "", _data);

Calling mint(uint256 _optionId, address _toAddress, uint256 _amount, bytes calldata _data) calls the internal

_mint(
    Option _option,
    address _toAddress,
    uint256 _amount,
    bytes memory _data
  ) 

Which ends up running

    if (id == 0) {
      id = nftContract.create(_toAddress, _amount, "", _data);
      optionToTokenID[optionId] = id;
    } else {
      nftContract.mint(_toAddress, id, _amount, _data);
    }

If the nftContract itself supports callback hooks (like MyCollectible.sol), there is a reentrancy which could allow create to be called twice with the same optionId

TransferProxy question

Hi, I've been trying to sell an OpenSea token on another marketplace for a few days now, and I can't quite figure out how to do it.
I have tested that from OpenSea to Rarible, and vice versa it is possible to synchronize, and sell tokens from one marketplace in the other.
I'm trying to do the same, but with another marketplace.
I'm reading some article out there, that says that in OpenSea, each user has a proxy contract?
Where is that contract? with that contract I should interact to give setApprovalForAll() to another contract (in this case erc1155) ?

Thanks!

Can't not mint again!

With opensea creatures, I deployed it on the rinkeby network, and I succeeded in minting with erc1155.
After minting, 3 OpenSeaCreatureItem sales were created.
After 4 days, I tried min again, but the operation ended without an error or success message. Can't I mint again after minting once?

Different Compiler Versions

The dependencies for these contracts all have different compiler versions. I'm not sure if Truffle accounts for that automatically, but it would be nice to a dist folder of contracts without dependencies referenced. Just a wall of contracts would be helpful.

/*
DESIGN NOTES:

  • We assume Class 0 is common!
  • Because this is a library we use a state struct rather than member
    variables. This struct is passes as the first argument to any functions that
    need it. This can make some function signatures look strange.
  • Because this is a library we cannot call owner(). We could include an owner
    field in the state struct, but this would add maintenance overhead for
    users of this library who have to make sure they change that field when
    changing the owner() of the contract that uses this library. We therefore
    append an _owner parameter to the argument list of functions that need to
    access owner(), which makes some function signatures (particularly _mint)
    look weird but is better than hiding a dependency on an easily broken
    state field.
  • We also cannot call onlyOwner or whenNotPaused. Users of this library should
    not expose any of the methods in this library, and should wrap any code that
    uses methods that set, reset, or open anything in onlyOwner().
    Code that calls _mint should also be wrapped in nonReentrant() and should
    ensure perform the equivalent checks to _canMint() in
    CreatureAccessoryFactory.
    */

I think this thinking is part of the problem. It is much better to use member variables here not just for other people developing, but end users reading the contract. Too many contracts all over the place doing god knows what.

Edit: Yikes, what a mess Truffle is. I'm just going to rewrite. I would recommend not using Truffle. It's an anti-pattern for open source development. You have way too many dependencies with too many points of failure using it. It makes it very difficult to pickup where you left off, and maintain things in the future.

There are dependencies of dependencies in this project, and all have different compiler versions. When you factor everything for one compiler version then you make things simple in the future, and you don't get caught off guard by other projects progressing for the sake of progressing. I think the intent here is to make it easy for others to come onboard, but Truffle is a giant roadblock. I know it makes testing and development slightly quicker when you are the only person doing it.

Edit 2:

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";doesn't comply with the state Open-Zeppelin recommendations on safe development. See: https://forum.openzeppelin.com/t/importing-openzeppelin-contracts-in-remix/1420

In addition, this repositories URL has been redirected. Just another reason to not use Truffle. Now I'm hunting down a compatible version of this, and since OpenSea didn't publish it, I can't be sure it's not opening a security flaw. Polymorphism is unavoidable sometimes but smart contracts should not turn into node projects where nobody understand the dependencies they inherit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.