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
Add folder of documentation to be pushed to our Documentation Platform (#1137)
* Add folder of documentation to be pushed to our Documentation Platform
* Add developer docs folder copy to docs workflow
---------
Co-authored-by: Ryan Ghods <ryan@ryanio.com>
-[Purchasing Items for Other Users](#purchasing-items-for-other-users)
@@ -43,15 +41,15 @@ A JavaScript library for crypto-native e-commerce: buying, selling, and bidding
43
41
44
42
This is the JavaScript SDK for [OpenSea](https://opensea.io), the largest marketplace for NFTs.
45
43
46
-
It allows developers to access the official orderbook, filter it, create buy orders (**offers**), create sell orders (**auctions**), and complete trades programmatically.
44
+
It allows developers to access the official orderbook, filter it, create buy orders (**offers**), create sell orders (**listings**), and complete trades programmatically.
47
45
48
46
Get started by [requesting an API key](https://docs.opensea.io/reference/api-keys) and instantiating your own OpenSea SDK instance. Then you can create orders off-chain or fulfill orders on-chain, and listen to events (like `ApproveAllAssets` or `WrapEth`) in the process.
49
47
50
48
Happy seafaring! ⛵️
51
49
52
50
## Installation
53
51
54
-
Switching to Node.js version 16 is required for SDK Version 3.0+ and to make sure common crypto dependencies work. Execute `nvm use`, if you have Node Version Manager.
52
+
Node.js version 16 is the minimum required for the SDK. Execute `nvm use`, if you have Node Version Manager.
When you make an offer on an item owned by an OpenSea user, **that user will automatically get an email notifying them with the offer amount**, if it's above their desired threshold.
171
169
172
-
#### Bidding on ENS Short Name Auctions
173
-
174
-
The Ethereum Name Service (ENS) is auctioning short (3-6 character) names that can be used for labeling wallet addresses and more. Learn more on the [ENS FAQ](https://opensea.io/ens).
175
-
176
-
To bid, you must use the ENS Short Name schema:
177
-
178
-
```typescript
179
-
const {
180
-
tokenId,
181
-
// Token address should be `0xfac7bea255a6990f749363002136af6556b31e04` on mainnet
182
-
tokenAddress,
183
-
// Name must have `.eth` at the end and correspond with the tokenId
184
-
name
185
-
} =ENS_ASSET// You can get an ENS asset from `openseaSDK.api.getAsset(...)`
186
-
187
-
const offer =awaitopenseaSDK.createBuyOrder({
188
-
asset: {
189
-
tokenId,
190
-
tokenAddress,
191
-
name,
192
-
// Only needed for the short-name auction, not ENS names
193
-
// that have been sold once already:
194
-
tokenStandard: "ENSShortNameAuction"
195
-
},
196
-
// Your wallet address (the bidder's address):
197
-
accountAddress: "0x1234..."
198
-
// Value of the offer, in wrapped ETH:
199
-
startAmount: 1.2,
200
-
})
201
-
```
202
-
203
170
#### Offer Limits
204
171
205
172
Note: The total value of buy orders must not exceed 1000 x wallet balance.
If the order is a buy order (`order.side === "bid"`), then the taker is the _owner_ and this will prompt the owner to exchange their item(s) for whatever is being offered in return. See [Listening to Events](#listening-to-events) below to respond to the setup transactions that occur the first time a user accepts a bid.
340
307
341
-
### Transferring Items or Coins (Gifting)
342
-
343
-
A handy feature in OpenSea.js is the ability to transfer any supported asset (fungible or non-fungible tokens) in one line of JavaScript.
344
-
345
-
To transfer an ERC-721 asset or an ERC-1155 asset, it's just one call:
346
-
347
-
```typescript
348
-
const transactionHash =awaitopenseaSDK.transfer({
349
-
asset: { tokenId, tokenAddress },
350
-
fromAddress, // Must own the asset
351
-
toAddress,
352
-
});
353
-
```
354
-
355
-
For fungible ERC-1155 assets, you can set `tokenStandard` to "ERC1155" and pass a `quantity` in to transfer multiple at once:
356
-
357
-
```typescript
358
-
const transactionHash =awaitopenseaSDK.transfer({
359
-
asset: {
360
-
tokenId,
361
-
tokenAddress,
362
-
tokenStandard: "ERC1155",
363
-
},
364
-
fromAddress, // Must own the asset
365
-
toAddress,
366
-
quantity: 2,
367
-
});
368
-
```
369
-
370
-
To transfer fungible assets without token IDs, like ERC20 tokens, you can pass in an `OpenSeaFungibleToken` as the `asset`, set `tokenStandard` to "ERC20", and include `quantity` in base units (e.g. wei) to indicate how many.
371
-
372
-
Example for transferring 2 DAI ($2) to another address:
For more information, check out the [documentation](https://projectopensea.github.io/opensea-js/).
391
-
392
308
## Advanced
393
309
394
310
Interested in purchasing for users server-side or with a bot, scheduling future orders, or making bids in different ERC-20 tokens? OpenSea.js can help with that.
@@ -398,7 +314,7 @@ Interested in purchasing for users server-side or with a bot, scheduling future
398
314
You can create sell orders that aren't fulfillable until a future date. Just pass in a `listingTime` (a UTC timestamp in seconds) to your SDK instance:
399
315
400
316
```typescript
401
-
constauction=awaitopenseaSDK.createSellOrder({
317
+
constorder=awaitopenseaSDK.createSellOrder({
402
318
tokenAddress,
403
319
tokenId,
404
320
accountAddress,
@@ -454,14 +370,9 @@ const order = await openseaSDK.api.getOrders({
454
370
});
455
371
```
456
372
457
-
**Fun note:** soon, all ERC-20 tokens will be allowed! This will mean you can create crazy offers on crypto collectibles **using your own ERC-20 token**. However, opensea.io will only display offers and auctions in ERC-20 tokens that it knows about, optimizing the user experience of order takers. Orders made with the following tokens will be shown on OpenSea:
- DAI, Maker's stablecoin, pegged to $1 USD: https://etherscan.io/token/0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359
461
-
462
373
### Private Auctions
463
374
464
-
Now you can make auctions and listings that can only be fulfilled by an address or email of your choosing. This allows you to negotiate a price in some channel and sell for your chosen price on OpenSea, **without having to trust that the counterparty will abide by your terms!**
375
+
You can make offers and listings that can only be fulfilled by an address or email of your choosing. This allows you to negotiate a price in some channel and sell for your chosen price on OpenSea, **without having to trust that the counterparty will abide by your terms!**
465
376
466
377
Here's an example of listing a Decentraland parcel for 10 ETH with a specific buyer address allowed to take it. No more needing to worry about whether they'll give you enough back!
Events are fired whenever transactions or orders are being created, and when transactions return receipts from recently mined blocks on the Ethereum blockchain.
485
396
486
-
Our recommendation is that you "forward" OpenSea events to your own store or state management system. Here's an example of doing that with a Redux action:
397
+
Our recommendation is that you "forward" OpenSea events to your own store or state management system. Here are examples of listening to the events:
0 commit comments