0.13.68-fix.22 • Published 3 days ago

@rarible/protocol-ethereum-sdk v0.13.68-fix.22

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
3 days ago

Rarible protocol ethereum Software Development Kit

Rarible protocol-ethereum-sdk enables applications to easily interact with Rarible protocol.

Installation

npm install -D @rarible/protocol-ethereum-sdk

With protocol-ethereum-sdk, you can:

  • Create sell orders
  • Create/accept bid for auctions
  • Buy tokens for regular sell orders
  • Create Lazy Mint NFT ERC721 and ERC1155 tokens
  • Make regular mint
  • Transfer tokens
  • Burn tokens

Usage

Below examples show how you can implement supported functions in you app.

Configure and create Rarible SDK object

import { createRaribleSdk } from "@rarible/protocol-ethereum-sdk"

const sdk = createRaribleSdk(web3, env, { fetchApi: fetch })
  • web3 - configured with your provider web3js client
  • env - environment configuration name, it should accept one of these values 'ropsten' | 'rinkeby' | 'mainnet' | 'e2e'

Create sell order

const order: Order = await sdk.order.sell(request).then(a => a.runAll())
// Sell request example:
const contractErc20Address: Address = '0x0' // your ERC20 contract address
const contractErc721Address: Address = '0x0' // your ERC721 contract address
const tokenId: BigNumber = '0x0' // the ERC721 Id of the token on which we want to place a bid
const sellerAddress: Address = '0x0' // Owner of ERC721 token
const nftAmount: number = 1 // For ERC721 always be 1
const sellPrice: number = 10 // price per unit of ERC721 or ERC1155 token(s)
const request = {
	makeAssetType: {
		assetClass: "ERC1155",
		contract: contractErc721Address,
		tokenId: tokenId,
	},
	maker: sellerAddress,
	amount: nftAmount,
	originFees: [],
	payouts: [],
	price: sellPrice,
	takeAssetType: {
		assetClass: "ERC20",
		contract: contractErc20Address
	},
}

Returns an object of created order.

Sell e2e test

Create bid

const order: Order = await sdk.order.bid(request).then(a => a.runAll())

// Bid request example:
const contractErc20Address: Address = '0x0' // your ERC20 contract address
const contractErc721Address: Address = '0x0' // your ERC721 contract address
const tokenId: BigNumber = '0x0' // the ERC721 Id of the token on which we want to place a bid
const sellerAddress: Address = '0x0' // Owner of ERC721 token
const buyerAddress: Address = '0x0' // Who make a bid
const nftAmount: number = 1 // For ERC721 always be 1
const bidPrice: number = 10 // price per unit of ERC721 or ERC1155 token(s)

const request = {
	makeAssetType: {
		assetClass: "ERC20",
		contract: contractErc20Address,
	},
	maker: buyerAddress,
	takeAssetType: {
		assetClass: "ERC721",
		contract: contractErc721Address,
		tokenId: tokenId,
	},
	taker: sellerAddress,
	amount: nftAmount,
	originFees: [],
	payouts: [],
	price: bidPrice,
}

Returns an object of created bid order.

Bid e2e test

Purchase order or accept bid (fill order)

const order: SimpleOrder

sdk.order.fill(
	order,
	{ payouts: [], originFees: [], amount: 1, infinite: true }
).then(a => a.runAll())

For example, you can get the order object using our sdk api methods sdk.apis.order.getSellOrders({}) and pass it to fill function. You can get more information in the test repository sell e2e test

Mint NFT Tokens

You can mint ERC721 and ERC1155 tokens in two ways:

  1. Regular "on chain" minting using contract.
  2. Off chain minting (the transaction itself and payment for gas occurs at the time of purchase or transfer).

You can use mint to create a token in different collections. Depending on the collection type, different mint requests should be sent to the function (isErc1155v1Collection, isErc1155v2Collection etc).

Mint function checks:

  • Request for MintOffChainResponse or MintOnChainResponse.
  • Token type: ERC721 or ERC1155.

Differences between mint functions in the presence of arguments creators, supply and lazy:

  • creators not use in ERC1155 v1
  • supply used only for ERC1155 v1 and v2
  • lazy is used if the passed collection supports lazy mint. Otherwise, the usual mint will be performed

For more information, see mint.ts.

ERC1155 V2 Lazy example:

return mint({
  collection,    // Collection info
  uri: "",       // Token URI
  royalties: [], // The amount of royalties
  supply: 1,     // Number of the tokens to mint, used only for ERC1155
  creators: [],  // Creators of token
  lazy: true,    // The token will be lazy minted or not
})

For more information, see mint.md.

Mint e2e test

Transfer

transfer(asset, to[, amount])

Transfer request params:

asset: {
    tokenId: BigNumber, // - id of token to transfer
    contract: Address, // - address of token contract
    assetClass?: "ERC721" | "ERC1155" // - not required, type of asset
}
to: Address, // - ethereum address of receiver of token
amount: BigNumber // - amount of asset to transfer, used only for ERC1155 assets

Example

const hash = await sdk.nft.transfer(
	{
		assetClass: "ERC1155",
		contract: toAddress(contractAddress),
		tokenId: toBigNumber(tokenId),
	},
	receiverAddress,
	toAddress('10')
)

Burn

const hash = await sdk.nft.burn({
	contract: contractAddress,
	tokenId: toBigNumber(tokenId),
})

Suggestions

You are welcome to suggest features and report bugs found! You can do it here: https://github.com/rarible/protocol-issues/issues

0.13.68-fix.22

3 days ago

0.13.69-beta.3

9 days ago

0.13.68-fix.21

17 days ago

0.13.68-fix.20

18 days ago

0.13.68-fix.19

24 days ago

0.13.68-fix.18

28 days ago

0.13.68-fix.17

1 month ago

0.13.68-fix.16

2 months ago

0.13.68-fix.14

2 months ago

0.13.68-fix.13

2 months ago

0.13.68-fix.12

2 months ago

0.13.68-fix.10

2 months ago

0.13.68-fix.11

2 months ago

0.13.68-fix.9

2 months ago

0.13.68-fix.8

2 months ago

0.13.68-fix.7

3 months ago

0.13.68-fix.6

3 months ago

0.13.68-fix.5

3 months ago

0.13.68-fix.4

3 months ago

0.13.69-beta.1

3 months ago

0.13.68-fix.3

3 months ago

0.13.69-beta.0

3 months ago

0.13.68-fix.1

3 months ago

0.13.68-fix.0

3 months ago

0.13.68-fix.2

3 months ago

0.13.67-fix.2

4 months ago

0.13.67-fix.0

4 months ago

0.13.67-fix.1

4 months ago

0.13.68

4 months ago

0.13.67

4 months ago

0.13.66

4 months ago

0.13.65

5 months ago

0.13.64-beta.5

5 months ago

0.13.64-beta.3

5 months ago

0.13.64-beta.2

5 months ago

0.13.64-beta.1

5 months ago

0.13.64-beta.0

5 months ago

0.13.62

5 months ago

0.13.50-beta.0

9 months ago

0.13.50-beta.1

9 months ago

0.13.50-beta.3

9 months ago

0.13.50-beta.5

9 months ago

0.13.60-beta.2

6 months ago

0.13.60-beta.1

6 months ago

0.13.60-beta.0

6 months ago

0.13.45

10 months ago

0.13.49

9 months ago

0.13.48

10 months ago

0.13.46

10 months ago

0.13.52

8 months ago

0.13.56

7 months ago

0.13.55

7 months ago

0.13.53

8 months ago

0.13.57

6 months ago

0.13.61

5 months ago

0.13.54-beta.1

7 months ago

0.13.51-hotfix.0

8 months ago

0.13.44-hotfix.2

11 months ago

0.13.44-hotfix.1

11 months ago

0.13.46-hotfix.1

10 months ago

0.13.40

11 months ago

0.13.44

11 months ago

0.13.43

11 months ago

0.13.42-hotfix.0

11 months ago

0.13.29

1 year ago

0.13.34

1 year ago

0.13.33

1 year ago

0.13.31

1 year ago

0.13.37

12 months ago

0.13.39

12 months ago

0.13.12

1 year ago

0.13.11

1 year ago

0.13.14

1 year ago

0.13.13

1 year ago

0.13.17

1 year ago

0.13.20

1 year ago

0.13.26

1 year ago

0.13.25

1 year ago

0.13.24

1 year ago

0.13.8

1 year ago

0.13.6

1 year ago

0.13.7

1 year ago

0.13.4

1 year ago

0.13.5

1 year ago

0.13.0

1 year ago

0.13.1

1 year ago

0.13.2

1 year ago

0.12.114

2 years ago

0.12.113

2 years ago

0.12.110

2 years ago

0.12.112

2 years ago

0.12.111

2 years ago

0.12.103

2 years ago

0.12.105

2 years ago

0.12.104

2 years ago

0.12.107

2 years ago

0.12.106

2 years ago

0.12.109

2 years ago

0.12.108

2 years ago

0.12.88

2 years ago

0.12.89

2 years ago

0.12.96

2 years ago

0.12.97

2 years ago

0.12.98

2 years ago

0.12.99

2 years ago

0.12.92

2 years ago

0.12.93

2 years ago

0.12.94

2 years ago

0.12.95

2 years ago

0.12.90

2 years ago

0.12.91

2 years ago

0.12.91-hotfix.0

2 years ago

0.12.102

2 years ago

0.12.101

2 years ago

0.12.100

2 years ago

0.12.74

2 years ago

0.12.75

2 years ago

0.12.76

2 years ago

0.12.77

2 years ago

0.12.73-hotfix.0

2 years ago

0.12.73

2 years ago

0.12.78

2 years ago

0.12.79

2 years ago

0.12.85

2 years ago

0.12.86

2 years ago

0.12.87

2 years ago

0.12.81

2 years ago

0.12.82

2 years ago

0.12.83

2 years ago

0.12.84

2 years ago

0.12.80

2 years ago

0.12.71

2 years ago

0.12.72

2 years ago

0.12.67

2 years ago

0.12.68

2 years ago

0.12.69

2 years ago

0.12.66-beta.1

2 years ago

0.12.66-alpha.12

2 years ago

0.12.66-beta.0

2 years ago

0.12.66-alpha.11

2 years ago

0.12.66-beta.3

2 years ago

0.12.66-alpha.10

2 years ago

0.12.66-beta.2

2 years ago

0.12.66-alpha.17

2 years ago

0.12.66-alpha.16

2 years ago

0.12.66-alpha.15

2 years ago

0.12.66-alpha.14

2 years ago

0.12.66-alpha.13

2 years ago

0.12.65-beta1

2 years ago

0.12.65-beta2

2 years ago

0.12.59

2 years ago

0.12.63

2 years ago

0.12.64

2 years ago

0.12.65

2 years ago

0.12.66

2 years ago

0.12.60

2 years ago

0.12.61

2 years ago

0.12.62

2 years ago

0.12.66-alpha.8

2 years ago

0.12.66-alpha.9

2 years ago

0.12.66-alpha.6

2 years ago

0.12.66-alpha.7

2 years ago

0.12.66-alpha.4

2 years ago

0.12.66-alpha.5

2 years ago

0.12.66-alpha.2

2 years ago

0.12.66-alpha.3

2 years ago

0.12.66-alpha.0

2 years ago

0.12.66-alpha.1

2 years ago

0.12.40-hotfix.2

2 years ago

0.12.40-hotfix.3

2 years ago

0.12.40-hotfix.0

2 years ago

0.12.40-hotfix.1

2 years ago

0.12.29

2 years ago

0.12.30

2 years ago

0.12.31

2 years ago

0.12.32

2 years ago

0.12.33

2 years ago

0.12.38

2 years ago

0.12.39

2 years ago

0.12.34

2 years ago

0.12.35

2 years ago

0.12.36

2 years ago

0.12.37

2 years ago

0.12.41

2 years ago

0.12.42

2 years ago

0.12.40

2 years ago

0.12.49

2 years ago

0.12.46

2 years ago

0.12.47

2 years ago

0.12.52

2 years ago

0.12.53

2 years ago

0.12.54

2 years ago

0.12.55

2 years ago

0.12.50

2 years ago

0.12.51

2 years ago

0.12.57

2 years ago

0.11.0

3 years ago

0.12.10

2 years ago

0.12.11

2 years ago

0.12.8

2 years ago

0.12.9

2 years ago

0.12.16

2 years ago

0.10.1

3 years ago

0.12.17

2 years ago

0.12.0

2 years ago

0.10.2

3 years ago

0.12.18

2 years ago

0.12.19

2 years ago

0.12.2

2 years ago

0.12.12

2 years ago

0.12.3

2 years ago

0.12.4

2 years ago

0.12.14

2 years ago

0.12.5

2 years ago

0.12.15

2 years ago

0.12.6

2 years ago

0.12.20

2 years ago

0.12.21

2 years ago

0.12.22

2 years ago

0.12.27

2 years ago

0.12.28

2 years ago

0.12.23

2 years ago

0.12.24

2 years ago

0.12.25

2 years ago

0.12.26

2 years ago

0.10.0

3 years ago

0.9.10

3 years ago

0.9.8

3 years ago

0.9.9

3 years ago

0.9.4

3 years ago

0.9.6

3 years ago

0.9.0

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.9.3

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.7.6

3 years ago

0.7.5

3 years ago

0.7.7

3 years ago

0.7.2

3 years ago

0.6.3

3 years ago

0.6.2

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.6.1

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.6.0

3 years ago

0.5.1

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.0

3 years ago

0.3.2

3 years ago

0.1.21

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.3.1

3 years ago

0.1.16

3 years ago

0.1.17

3 years ago

0.1.15

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.3

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago