Skip to content

Commit

Permalink
Updating CodeExamples.md
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions Bot committed Oct 14, 2024
1 parent 6ad9798 commit 9ffee5a
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions CodeExamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ you need to mint oceans to mentioned accounts only if you are using barge to tes

### 6.1 Publish a dataset (create NFT + Datatoken) with a fixed rate exchange
```Typescript
const factory = new NftFactory(addresses.ERC721Factory, publisherAccount)
const factory = new NftFactory(
addresses.ERC721Factory,
publisherAccount,
await publisherAccount.getChainId()
)

const nftParams: NftCreateData = {
name: FRE_NFT_NAME,
Expand Down Expand Up @@ -326,8 +330,7 @@ you need to mint oceans to mentioned accounts only if you are using barge to tes
const bundleNFT = await factory.createNftWithDatatokenWithFixedRate(
nftParams,
datatokenParams,
freParams,
false
freParams
)

const trxReceipt = await bundleNFT.wait()
Expand Down Expand Up @@ -410,7 +413,11 @@ Now let's console log the DID to check everything is working

### 6.3 Marketplace displays fixed rate asset for sale
```Typescript
const fixedRate = new FixedRateExchange(freAddress, publisherAccount)
const fixedRate = new FixedRateExchange(
freAddress,
publisherAccount,
await publisherAccount.getChainId()
)
const oceanAmount = await (
await fixedRate.calcBaseInGivenDatatokensOut(freId, '1')
).baseTokenAmount
Expand All @@ -425,7 +432,7 @@ Now that the market has fetched those values it can display the asset on the fro

### 7.1 Consumer buys a fixed rate asset data asset, and downloads it
```Typescript
datatoken = new Datatoken(publisherAccount)
datatoken = new Datatoken(publisherAccount, await publisherAccount.getChainId())
const DATATOKEN_AMOUNT = '10000'

await datatoken.mint(
Expand Down Expand Up @@ -474,7 +481,11 @@ Before we call the contract we have to call `approve` so that the contract can m
DATATOKEN_AMOUNT
)

const fixedRate = new FixedRateExchange(freAddress, consumerAccount)
const fixedRate = new FixedRateExchange(
freAddress,
consumerAccount,
await consumerAccount.getChainId()
)
```
Now we can make the contract call
```Typescript
Expand Down Expand Up @@ -518,7 +529,7 @@ Next, we need to initialize the provider
validUntil: initializeData.providerFee.validUntil
}

datatoken = new Datatoken(consumerAccount)
datatoken = new Datatoken(consumerAccount, await consumerAccount.getChainId())

```
Lets now make the payment
Expand Down Expand Up @@ -575,7 +586,11 @@ Lets check that the download URL was successfully received

### 8.1 Publish a dataset (create NFT + Datatoken) with a dispenser
```Typescript
const factory = new NftFactory(addresses.ERC721Factory, publisherAccount)
const factory = new NftFactory(
addresses.ERC721Factory,
publisherAccount,
await publisherAccount.getChainId()
)

const nftParams: NftCreateData = {
name: DISP_NFT_NAME,
Expand Down Expand Up @@ -607,8 +622,7 @@ Lets check that the download URL was successfully received
const bundleNFT = await factory.createNftWithDatatokenWithDispenser(
nftParams,
datatokenParams,
dispenserParams,
false
dispenserParams
)
const trxReceipt = await bundleNFT.wait()
const nftCreatedEvent = getEventFromTx(trxReceipt, 'NFTCreated')
Expand Down Expand Up @@ -681,8 +695,12 @@ Now we need to encrypt file(s) using provider

### 9.1 Consumer gets a dispenser data asset, and downloads it
```Typescript
datatoken = new Datatoken(publisherAccount)
const dispenser = new Dispenser(addresses.Dispenser, consumerAccount)
datatoken = new Datatoken(publisherAccount, await publisherAccount.getChainId())
const dispenser = new Dispenser(
addresses.Dispenser,
consumerAccount,
await consumerAccount.getChainId()
)

let consumerDTBalance = await balance(
consumerAccount,
Expand Down Expand Up @@ -711,7 +729,7 @@ Now we need to encrypt file(s) using provider
const resolvedDDO = await aquarius.waitForAqua(fixedDDO.id)
assert(resolvedDDO, 'Cannot fetch DDO from Aquarius')

datatoken = new Datatoken(consumerAccount)
datatoken = new Datatoken(consumerAccount, await consumerAccount.getChainId())

```
At this point we need to encrypt file(s) using provider
Expand Down Expand Up @@ -793,7 +811,7 @@ Here are the steps:
### 10.1 Add key-value pair to data NFT
Let's start by using the `setData` method to update the nft key value store with some data
```Typescript
const nft = new Nft(publisherAccount)
const nft = new Nft(publisherAccount, await publisherAccount.getChainId())
const data = 'SomeData'
try {
await nft.setData(
Expand Down

0 comments on commit 9ffee5a

Please sign in to comment.