1.6.53 • Published 1 year ago

permaweb-orderbook v1.6.53

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Orderbook sdk

Install

npm install permaweb-orderbook

Initialize

Optionally when initializing, you can specify a different instance of arweave for querying/posting, for example if you want to post to arweave.net and retrieve from goldsky. Below we are using the same instance for both.

import Arweave from 'arweave';
import { defaultCacheOptions, WarpFactory } from 'warp-contracts';
import { OrderBook } from 'permaweb-orderbook';

let arweave = Arweave.init({
	host: 'arweave.net',
	port: 443,
	protocol: 'https,
	timeout: 40000,
	logging: false,
});

let warp = WarpFactory.forMainnet({
	...defaultCacheOptions,
	inMemory: true,
});

let orderbook = OrderBook.init({
	currency: 'U',
	arweaveGet: arweaveGet,
	arweavePost: arweavePost,
	warp: warp,
	warpDreNode: 'https://dre-u.warp.cc/contract'
});

Limit Sell Market Buy Limit Buy Market Sell

Sell an asset

// Limit sell
let orderTx = await orderbook.sell({
	assetId: 'jsDyuWAfDpvng789iOpoG9GJpd91VayNizlFzOyNiRE',
	qty: 10, // quantity of asset to sell
	price: unitPrice, // unit price in subunits
	wallet: 'use_wallet',
	walletAddress: walletAddress,
});

console.log(orderTx);

Buy an asset

let orderTx = await orderbook.buy({
	assetId: 'jsDyuWAfDpvng789iOpoG9GJpd91VayNizlFzOyNiRE',
	// amount of sub $U to spend
	spend: 1000,
	wallet: 'use_wallet',
	walletAddress: walletAddress,
});

console.log(orderTx);

Asset Requirements

In order to list an asset for sale (call the sell function on it successfully) it must meet the following requirements - Must be an atomic asset where the id represents both the contract and the data - the contract must have state - the contract state must have balances and claimable array - the asset must be retrievable via id on the the gateway directly (arweave.net/txid) and via gql (by id query), it cannot be 404 - it must contain ANS-110 Title, Description, and Type tags, https://specs.g8way.io/?tx=SYHBhGAmBo6fgAkINNoRtumOzxNB8-JFv2tPhBuNk5c

1.6.53

1 year ago

1.6.44

2 years ago

1.6.46

2 years ago

1.6.45

2 years ago

1.6.48

2 years ago

1.6.47

2 years ago

1.6.49

2 years ago

1.6.51

2 years ago

1.6.50

2 years ago

1.6.52

2 years ago

1.6.4

2 years ago

1.6.42

2 years ago

1.6.41

2 years ago

1.6.43

2 years ago

1.6.31

2 years ago

1.6.3

2 years ago

1.6.2

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.99

2 years ago

1.5.98

2 years ago

1.5.97

2 years ago

1.5.96

2 years ago

1.5.95

2 years ago

1.5.94

2 years ago

1.5.93

2 years ago

1.5.92

2 years ago

1.5.91

2 years ago

1.5.9

2 years ago

1.5.8

2 years ago

1.5.7

2 years ago

1.5.6

2 years ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.63

2 years ago

1.3.62

2 years ago

1.3.61

2 years ago

1.3.6

2 years ago

1.3.53

2 years ago

1.3.52

2 years ago

1.3.51

2 years ago

1.3.5

2 years ago

1.3.40

2 years ago

1.3.39

2 years ago

1.3.38

2 years ago

1.3.37

2 years ago

1.3.36

2 years ago

1.3.35

2 years ago

1.3.34

2 years ago

1.3.33

2 years ago

1.3.32

2 years ago

1.3.31

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.99

2 years ago

1.2.98

2 years ago

1.2.97

2 years ago

1.2.96

2 years ago

1.2.95

2 years ago

1.2.94

2 years ago

1.2.93

2 years ago

1.2.92

2 years ago

1.2.91

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago