0.5.78-fix.3 • Published 3 months ago

@rarible/flow-sdk v0.5.78-fix.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Flow SDK

Installation

npm i -S @rarible/flow-sdk

Usage

Simple code example

Quick start

  1. Configure fcl
  2. Create and use flow-sdk

Configure fcl

Flow-sdk use @onflow/fcl-js. You can find configuration details for fcl in this page

//example config for testnet
import { config } from "@onflow/fcl";

config({
  "accessNode.api": "https://access-testnet.onflow.org", // Mainnet: "https://access-mainnet-beta.onflow.org"
  "discovery.wallet": "https://fcl-discovery.onflow.org/testnet/authn" // Mainnet: "https://fcl-discovery.onflow.org/authn"
})

Create and use flow-sdk

Then we create the SDK according to the network that we configured in the previous step.

import { createFlowSdk } from "@rarible/flow-sdk"
import * as fcl from "@onflow/fcl"

const sdk = createFlowSdk(fcl, "testnet")

Minting

Mint response represents transaction result extended with txId and minted tokenId

import { toFlowContractAddress } from "@rarible/flow-sdk"
import { toFlowAddress } from "@rarible/types"

// collection = Contact address A.[contactAddress].[contractName]
const collection = toFlowContractAddress("A.0x1234567890abcdef.RaribleNFT")
// royalties - array of objects: {account: FlowAddress, value: BigNumber}, value must be a number between 0 and 1
const royalties = [{ account: toFlowAddress("0x1234567890abcdef"), value: toBigNumber("0.1") }]
const metaData = "your meta info" // usually ipfs url

const { tokenId } = await sdk.nft.mint(collection, metaData, royalties)

Returns FlowTransaction object with minted tokenId

Transfer

import { toFlowAddress } from "@rarible/types"
import { toFlowContractAddress } from "@rarible/flow-sdk"

const collection = toFlowContractAddress("A.0x1234567890abcdef.RaribleNFT")
const tokenId = 123
const receiver = toFlowAddress("0x1234567890abcdef")

const tx = await sdk.nft.transfer(collection, tokenId, receiver)

Returns FlowTransaction object

Burn

import { toFlowContractAddress } from "@rarible/flow-sdk"

const collection = toFlowContractAddress("A.0x1234567890abcdef.RaribleNFT")
const tokenId = 123

const tx = await sdk.nft.burn(collection, tokenId)

Returns FlowTransaction object

Create sell order

import { toFlowContractAddress, toFlowItemId } from "@rarible/flow-sdk"

const collection = toFlowContractAddress("A.0x1234567890abcdef.RaribleNFT")
const itemId = toFlowItemId(`${collection}:123`)
const tx = await sdk.nft.sell(collection, currency, itemId, price)

/** supported currencies for now "FLOW" and "FUSD" */

/** FlowItemId you can find in FlowNftItem response from api,
 for example sdk.apis.item.getNftItemsByOwner({address: <your account address>})
 */

/** price must be a string of flow fungible token amount with 8 decimals,  for example: 1.123 or 0.1 or 0.00000001 */

Returns FlowTransaction object with orderId

Update order

const tx = await sdk.nft.updateOrder(collection, currency, orderId, price)
// orderId can be a orderId number or full FlowOrder object received from order api

Returns FlowTransaction object with updated orderId

Cancel order

const tx = await sdk.nft.cancelOrder(collection, orderId)

Returns FlowTransaction object

Buy an item

const tx = await sdk.nft.fill(collection, orderId, owner)
// owner: FlowAddress - order owner address

Returns FlowTransaction object

Create bid

import { toFlowContractAddress, toFlowItemId } from "@rarible/flow-sdk"

const collection = toFlowContractAddress("A.0x1234567890abcdef.RaribleNFT")
const itemId = toFlowItemId(`${collection}:123`)
const tx = await sdk.nft.bid(collection, currency, itemId, price)
// params the same as regular order creation

Returns FlowTransaction object with orderId

Update bid

const tx = await sdk.nft.updateBid(collection, currency, bidId, price)

Returns FlowTransaction object with updated orderId

Cancel bid

const tx = await sdk.nft.cancelBid(collection, bidId)

Returns FlowTransaction object

Accept bid

The same as buy order sdk.order.fill

Get account fungible tokens balance

const balance = await sdk.wallet.getFungibleBalance(accountAddress, "FUSD")
0.5.78-fix.3

3 months ago

0.5.78-fix.2

3 months ago

0.5.78-fix.1

3 months ago

0.5.78-fix.0

3 months ago

0.5.78

3 months ago

0.5.76-beta.0

4 months ago

0.5.77-fix.0

4 months ago

0.5.77-fix.1

4 months ago

0.5.77

4 months ago

0.5.76

5 months ago

0.5.73-fix.0

6 months ago

0.5.74

6 months ago

0.5.72

7 months ago

0.5.73

6 months ago

0.5.70

11 months ago

0.5.71

9 months ago

0.5.69

11 months ago

0.5.75-fix.1

6 months ago

0.5.74-fix.0

6 months ago

0.5.74-fix.1

6 months ago

0.5.65

11 months ago

0.5.66

11 months ago

0.5.63

12 months ago

0.5.64

12 months ago

0.5.61

1 year ago

0.5.62

12 months ago

0.5.60

1 year ago

0.5.67

11 months ago

0.5.68

11 months ago

0.5.59

1 year ago

0.5.54

1 year ago

0.5.55

1 year ago

0.5.52

1 year ago

0.5.53

1 year ago

0.5.50

1 year ago

0.5.51

1 year ago

0.5.58

1 year ago

0.5.56

1 year ago

0.5.57

1 year ago

0.5.48-alpha.0

2 years ago

0.5.48-alpha.1

2 years ago

0.5.48-alpha.2

2 years ago

0.5.48-alpha.3

2 years ago

0.5.48-alpha.5

2 years ago

0.5.47

2 years ago

0.5.41-alpha.1

2 years ago

0.5.33-alpha.28

2 years ago

0.5.33-alpha.27

2 years ago

0.5.42-alpha.2

2 years ago

0.5.42-alpha.1

2 years ago

0.5.43

2 years ago

0.5.44

2 years ago

0.5.40

2 years ago

0.5.45

2 years ago

0.5.46

2 years ago

0.5.39

2 years ago

0.5.33-alpha.26

2 years ago

0.5.30-ac.0

2 years ago

0.5.33-alpha.10

2 years ago

0.5.33-alpha.12

2 years ago

0.5.33-alpha.11

2 years ago

0.5.33-alpha.18

2 years ago

0.5.33-alpha.17

2 years ago

0.5.33-alpha.19

2 years ago

0.5.33-alpha.14

2 years ago

0.5.33-alpha.13

2 years ago

0.5.33-alpha.16

2 years ago

0.5.33-alpha.15

2 years ago

0.5.33-alpha.21

2 years ago

0.5.29-hotfix.1

2 years ago

0.5.33-alpha.20

2 years ago

0.5.33-alpha.23

2 years ago

0.5.33-alpha.22

2 years ago

0.5.29-hotfix.0

2 years ago

0.5.33-alpha.25

2 years ago

0.5.33-alpha.24

2 years ago

0.5.30-alpha.0

2 years ago

0.5.30-alpha.2

2 years ago

0.5.30-alpha.1

2 years ago

0.5.30-alpha.4

2 years ago

0.5.30-alpha.3

2 years ago

0.5.30-alpha.6

2 years ago

0.5.30-alpha.5

2 years ago

0.5.30-alpha.8

2 years ago

0.5.30-alpha.7

2 years ago

0.5.32

2 years ago

0.5.33

2 years ago

0.5.30

2 years ago

0.5.31

2 years ago

0.5.33-alpha.3

2 years ago

0.5.38

2 years ago

0.5.33-alpha.4

2 years ago

0.5.33-alpha.5

2 years ago

0.5.36

2 years ago

0.5.37

2 years ago

0.5.34

2 years ago

0.5.33-alpha.0

2 years ago

0.5.35

2 years ago

0.5.33-alpha.1

2 years ago

0.5.33-alpha.6

2 years ago

0.5.33-alpha.7

2 years ago

0.5.33-alpha.8

2 years ago

0.5.29

2 years ago

0.5.10

2 years ago

0.5.11

2 years ago

0.5.18

2 years ago

0.5.19

2 years ago

0.5.16

2 years ago

0.5.17

2 years ago

0.5.14

2 years ago

0.5.12

2 years ago

0.5.13

2 years ago

0.5.20-alpha.0

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.0

2 years ago

0.3.2

3 years ago

0.5.2

2 years ago

0.3.4

2 years ago

0.5.1

2 years ago

0.5.8

2 years ago

0.5.9

2 years ago

0.5.21

2 years ago

0.5.22

2 years ago

0.5.27

2 years ago

0.5.28

2 years ago

0.5.25

2 years ago

0.5.26

2 years ago

0.5.23

2 years ago

0.5.24

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.5.21-alpha.0

2 years ago

0.4.2

2 years ago

0.3.0

3 years ago

0.1.1

3 years ago

0.3.1

3 years ago

0.0.95

3 years ago

0.0.96

3 years ago

0.0.98

3 years ago

0.0.99

3 years ago

0.0.101

3 years ago

0.0.100

3 years ago

0.0.93

3 years ago

0.0.94

3 years ago

0.1.0

3 years ago

0.0.87

3 years ago

0.0.88

3 years ago

0.0.89

3 years ago

0.0.90

3 years ago

0.0.91

3 years ago

0.0.92

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago