Coder Social home page Coder Social logo

thirdweb-dev / contracts Goto Github PK

View Code? Open in Web Editor NEW
926.0 926.0 466.0 20.22 MB

Collection of smart contracts deployable via thirdweb

Home Page: https://docs.thirdweb.com/contracts

License: Apache License 2.0

Shell 0.02% Solidity 99.25% TypeScript 0.73%
ethereum smart-contracts solidity web3

contracts's People

Contributors

0xfirekeeper avatar adam-maj avatar alfheimrshiven avatar atbe avatar atharvadeosthale avatar ciaranightingale avatar furqanrydhan avatar goldnite avatar jakeloo avatar jarrodwatts avatar jnsdls avatar joaquim-verges avatar kumaryash90 avatar mmeigooni avatar mykcryptodev avatar nachoiacovino avatar ndeto avatar nkrishang avatar omahs avatar ryleysill93 avatar saarthdeshpande avatar warengonzaga avatar whiteoakkong avatar xiaolou86 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

contracts's Issues

Allow for marketplace bids in layer 1 currencies (ETH, MATIC, Avalanche)

Hi there,

Following the tutorial for creating a marketplace and am trying to create a bid as described here: https://nftlabs.github.io/nftlabs-sdk-ts/sdk.marketplacemodule.createauctionlisting.html

// Data of the auction you want to create
const auction = {
  // address of the contract the asset you want to list is on
  assetContractAddress: "0x...",
  // token ID of the asset you want to list
  tokenId: "0",
  // in how many seconds with the listing open up
  startTimeInSeconds: 0,
  // how long the listing will be open for
  listingDurationInSeconds: 86400,
  // how many of the asset you want to list
  quantity: 1,
  // address of the currency contract that will be used to pay for the listing
  currencyContractAddress: "0x0000000000000000000000000000000000000000",
  // how much people would have to bid to instantly buy the asset
  buyoutPricePerToken: "10",
  // the minimum bid that will be accepted for the token
  reservePricePerToken: "1",
}

await module.createAuctionListing(auction);

I get that currencyContractAddress takes an ERC20 contract address to pay with. My question is can we add the feature to pay with raw ETH (and similarly on other coins as well). I can use wrapped ETH fine but it is annoying for users to pay gas to swap in order to buy.

Thank you for your consideration.

ERC721A

It would be great to see @thirdweb-dev adopt ERC721A, an improved implementation of the IERC721 standard that supports minting multiple tokens for close to the cost of one.

The goal of ERC721A is to provide a fully compliant implementation of IERC721 with significant gas savings for minting multiple NFTs in a single transaction.

The Azuki team (created by @chiru-labs) created ERC721A for its sale on 1/12/22. There was significant demand for 8700 tokens made available to the public, and all were minted within minutes. The network BASEFEE remained low despite huge demand, resulting in low gas costs for minters, while minimizing network disruption for the wider ecosystem as well.

What's the easiest way to implement ERC721A into thirdweb?

Check out the nft-erc721-collection by @hashlips-lab

Get ERC721 contract for lazy minting on par with the ERC1155 contract (LazyMintERC1155)

The LazyMintERC1155 contract improved upon the ERC721 contract for lazy minting (LazyNFT) in the following ways:

  • Gas efficient pattern for lazy minting (no for loops for lazy minting multiple NFTs)
  • Clearer usage of 'mint' and 'claim' (e.g. rename setPublicMintConditions -> setClaimConditions)
  • Make external/public functions more readable by using internal functions, where each internal function has a defined, single task to perform. So, external/public functions read like pseudo-code. (see claim in LazyMintERC1155)

To-do :

  • Re-write LazyNFT as LazyMintERC721 and make changes described above.
  • Document the changes that break the interface of the contract so the SDK can be adjusted accordingly.

adding timestamps to offers on `Marketplace`

It would be nice to see when offers are made on marketplace auction listings. This increases transparency. I am willing to submit a Pull Request to add this new feature.

The changed Offer structure would look something like this:

struct Offer {
        uint256 listingId;
        address offeror;
        uint256 quantityWanted;
        address currency;
        uint256 pricePerToken;
        uint256 expirationTimestamp;
        uint256 createdAtTimestamp;
}

Fix bidding bug

If you're required to transfer the $ into the contract for a bid, it seems like you're competing against yourself.
If i have 100 in my wallet, i bid 90 and that get transferred into the contract. The next bid that i make i can only make it up to 10.

Design doc for ERC1155 lazy minting

A design doc for ERC 1155 lazy minting (similar to the existing LazyNFT) - explaining what the contract is, how it works and can be used, and why it is design the way it is.

Failed to get upload token

Hi when I run the 2-deploy-drop.js in Buildspace project Build your own DAO with just Javascript in a weekend. I get an error. Could anyone help ? Thanks

Below is the code and the error info.

`import { AddressZero } from "@ethersproject/constants";
import sdk from "./1-initialize-sdk.js";
import { readFileSync } from "fs";

(async () => {
try {
const editionDropAddress = await sdk.deployer.deployEditionDrop({
// The collection's name, ex. CryptoPunks
name: "shushuDAO Membership",
// A description for the collection.
description: "A DAO for fans of SHUSHU.",
// The image that will be held on our NFT! The fun part :).
image: readFileSync("scripts/assets/1.png"),
// We need to pass in the address of the person who will be receiving the proceeds from sales of nfts in the contract.
// We're planning on not charging people for the drop, so we'll pass in the 0x0 address
// you can set this to your own wallet address if you want to charge for the drop.
primary_sale_recipient: AddressZero,
});

// this initialization returns the address of our contract
// we use this to initialize the contract on the thirdweb sdk
const editionDrop = sdk.getEditionDrop(editionDropAddress);

// with this, we can get the metadata of our contract
const metadata = await editionDrop.metadata.get();

console.log(
  "✅ Successfully deployed editionDrop contract, address:",
  editionDropAddress,
);
console.log("✅ editionDrop metadata:", metadata);

} catch (error) {
console.log("failed to deploy editionDrop contract", error);
}
})();`

failed to deploy editionDrop contract FetchError: FETCH_FAILED: Failed to get upload token
at zt.getUploadToken (D:\tt\buildspace-dao-starter\node_modules@thirdweb-dev\sdk\dist\index.js:15:1748)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async zt.uploadBatchWithCid (D:\tt\buildspace-dao-starter\node_modules@thirdweb-dev\sdk\dist\index.js:15:3119)
at async zt.batchUploadProperties (D:\tt\buildspace-dao-starter\node_modules@thirdweb-dev\sdk\dist\index.js:15:2723)
at async zt.uploadMetadataBatch (D:\tt\buildspace-dao-starter\node_modules@thirdweb-dev\sdk\dist\index.js:15:2098)
at async zt.uploadMetadata (D:\tt\buildspace-dao-starter\node_modules@thirdweb-dev\sdk\dist\index.js:15:2002)
at async pa.deploy (D:\tt\buildspace-dao-starter\node_modules@thirdweb-dev\sdk\dist\index.js:15:249292)
at async Pn.deployBuiltInContract (D:\tt\buildspace-dao-starter\node_modules@thirdweb-dev\sdk\dist\index.js:15:252554)
at async Pn.deployEditionDrop (D:\tt\buildspace-dao-starter\node_modules@thirdweb-dev\sdk\dist\index.js:15:251978)
at async file:///D:/tt/buildspace-dao-starter/scripts/2-deploy-drop.js:7:32 {
innerError: undefined

Design doc for v2 market

A markdown document detailing what the v2 market contract is, and the rationale for why it's designed the way it is.

RE: `v2/MarketWithAuction`: Fix vulnerability with offers to direct listings

There are no bids in the case of a direct listing, so no funds related to direct listings are escrowed in the Marketplace. 

However, there is a possible vulnerability with 'offers to direct listings'. 



Problem
Say there are 2 listings: L_1 which accepts currency A and L_2 which accepts currency B. Both are selling 1 NFT, and have the same price per token.

The same buyer makes an offer of amount x to L_1 in currency A, and L_2 in currency B. This means the buyer has approved the Marketplace to transfer x currency A and x currency B.

If L_2 edits its 'currency accepted' to currency A, then the lister of L_2 can accept the buyer's offer on L_2, since the Marketplace has the buyer's approval to transfer x currency A from the buyer's offer to L_1. However, the buyer may not have intended to buy from L_2 with currency A. This is an issue. 



Solution — Store an offer's intended currency in the Offer struct, so a buyer makes an offer with an offer amount and a currency specified.

Return the auctioned items to auction creator if the auction receives no bids

See the case described in (3), in this this discussion.

Bug

Two separate issues pointed out:

1. An auction creator can make a winning bid in the auction, but the auction cannot be closed for the auction creator as the wining bidder. In this snippet if _closeFor is both targetBid.tokenOwner and targetBid.offeror, then _closeAuctionForBidder never gets called.

2. We need a one-step, more gas efficient way to handle the case described above in (3).

Fix Close auction and execute sale if there's a buyout price and incoming offer amount is buyout price.

Hello,
I am reporting a bug on Close auction and execute sale if there's a buyout price and incoming offer amount is buyout price.

BUG

you are not collecting incoming bid

Expected

Collect incoming bid after _closeAuctionForBidder so that you have funds to pay the auction creator

I have included the ref below

_closeAuctionForBidder(_targetListing, _incomingBid);

How to reproduce:

  • Create and auction with a buyoutPricePerToken > 0
  • try to bid the auction from another address (user A) with a buyoutPricePerToken that >= to the buyoutPricePerToken price above
  • now close the auction from user A who is the buyer, this works ✔️
  • now try to close the auction with user B who is the auction creator, the tx reverts ❌
  • Execution will revert coz there are no funds to to pay the auction creator
    sometime it reverts with just execution reverted or Error: VM Exception while processing transaction: reverted with reason string 'ERC20: burn amount exceeds balance

Create an ERC-1155 collection

Hello team,

  • I'm trying to create + deploy an ERC-1155 contract to Rinkeby testnet following the guide from Buildspace.

  • However, when I run my script "scripts/2-deploy-drop.js" I get the following error below.

  • "failed to deploy editionDrop contract TypeeERROR: failed to execute 'append on 'FormDate': parameter 2 is not of type 'Blob'"
    Screenshot 2022-09-17 at 10 32 28

  • This is a screenshot of the code within the script below:
    code

  • Any suggestions on how to resolve this error would be greatly appreciated, thanks.

User/Owner Separation for NFTs - EIP4907 Integration

The EIP-4907 standard makes it possible for tokens created with the ERC721 standard to be used in rental transactions. In this way, the owner and user of tokens can be separate wallets. For example, an NFT collection distributes ERC20 tokens to its users through passive staking, a user who does not yet have an NFT leases one and becomes the user of NFT. Thus, the user can earn ERC20 tokens.

This Ethereum improvement proposal helps with separating user and ownership. Although it is not a very common usage yet, it may be useful to have this option available for use among ready-to-use contracts.

The explanation of the relevant EIP is given in the link below:
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4907.md

Change `offerAmount` to `pricePerToken`

Re: v2/MarketWithAuction

To maintain a consistent interface throughout the contract, we’ll change the Offer struct code to use pricePerToken instead of totalOfferAmount, and implicitly calculate the ‘total offer amount’ as price per token offered * quantity of tokens wanted.

Marketplace invalid tuple value Remix

Hello ! im try to use Remix to deploy Marketplace smart contract but i get invalid tuple value from remix what im doing wrong?

params_ = { assetContract: '0x455136fb85bA2b6378B9Ad34750440B508194a95', tokenId: '5', startTime: 0, secondsUntilEndTime: 86400, quantityToList: 1, currencyToAccept: '0x0000000000000000000000000000000000000000', buyoutPricePerToken: '10', reservePricePerToken: '1', listingType: 2, }
image

remix error: transact to Marketplace.createListing errored: Error encoding arguments: Error: invalid tuple value (argument="tuple", value="{ assetContract: '0x455136fb85bA2b6378B9Ad34750440B508194a95', tokenId: '5', startTime: 0, secondsUntilEndTime: 86400, quantityToList: 1, currencyToAccept: '0x0000000000000000000000000000000000000000', buyoutPricePerToken: '10', reservePricePerToken: '1', listingType: 2, }", code=INVALID_ARGUMENT, version=abi/5.5.0)

Design doc + interface for 'signature based minting'

Customer need : an end user must be able to mint an NFT without the thirdweb customer having to pay gas to mint or lazy mint the NFT beforehand.

To-do :

  • Write a design doc documenting the high level strategy for writing the smart contract that enables the mentioned customer need.
  • Write the interface for the mentioned smart contract.

How to run tests?

Hi

i'm curious how to run the tests?
When I run npm run tests or yarn tests it seems to do something silently but at the end it states "0 passing":

❯ npm run test

> @thirdweb-dev/[email protected] test
> hardhat test

No need to generate any newer typings.
✅ Generated documentation for 120 contracts


  0 passing (0ms)

Can buy your own NFT

The marketplace contract is set up in a way that allows someone to buy their own NFT. Would it be better if from the get go no person was able to buy a listed NFT that they own?

ERC20 version of Drop

An ERC20 version of the thirdweb 'Drop' module (i.e. /contracts/lazy_mint/), where a module admin can set claim conditions, and relevant ERC20 tokens can be claimed according to those claim conditions.

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.