1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

GitBook: [#6] No subject

This commit is contained in:
Akshay Patel 2022-07-25 10:17:51 +00:00 committed by gitbook-bot
parent 772ec9bbf6
commit ea9bf24500
No known key found for this signature in database
GPG Key ID: 07D2180C7B12D0FF
4 changed files with 237 additions and 2 deletions

View File

@ -24,7 +24,10 @@
* [Obtaining Ethereum node provider API key](building-with-ocean/obtaining-api-key.md)
* [Using Ocean libraries](building-with-ocean/using-ocean-libraries/README.md)
* [Configuration](building-with-ocean/using-ocean-libraries/configuration.md)
* [Creating a dataNFT](building-with-ocean/using-ocean-libraries/creating_dataNFT.md)
* [Creating a dataNFT](building-with-ocean/using-ocean-libraries/creating\_dataNFT.md)
* [Create Datatoken with fixed pricing](building-with-ocean/using-ocean-libraries/create-datatoken-with-fixed-pricing.md)
* [Mint datatoken](building-with-ocean/using-ocean-libraries/mint-datatoken.md)
* [Update metadata](building-with-ocean/using-ocean-libraries/update-metadata.md)
* [Publish assets using hosting services](building-with-ocean/asset-hosting.md)
* [Binance Smart Chain (BSC)](building-with-ocean/bsc-bridge.md)
* [Set Up a Marketplace](building-with-ocean/marketplace.md)

View File

@ -0,0 +1,126 @@
# Create Datatoken with fixed pricing
#### Configuration
See [this](configuration.md) guide on defining a `.env` file and a configuration file
#### Create a script to deploy dataNFT and datatoken with fixed pricing.
{% tabs %}
{% tab title="ocean.js" %}
{% code title="create_datatoken_with_fre.js" %}
```javascript
const { NftFactory, Datatoken } = require('@oceanprotocol/lib');
const Web3 = require('web3');
const { web3Provider, oceanConfig } = require('./config');
const web3 = new Web3(web3Provider);
const createDataNFT = async () => {
const Factory = new NftFactory(oceanConfig.erc721FactoryAddress, web3);
const accounts = await web3.eth.getAccounts();
const publisherAccount = accounts[0];
const nftParams = {
name: '72120Bundle',
symbol: '72Bundle',
templateIndex: 1,
tokenURI: 'https://example.com',
transferable: true,
owner: publisherAccount
};
const erc20Params = {
templateIndex: 1,
cap: '100000',
feeAmount: '0',
paymentCollector: '0x0000000000000000000000000000000000000000',
feeToken: '0x0000000000000000000000000000000000000000',
minter: publisherAccount,
mpFeeAddress: '0x0000000000000000000000000000000000000000'
};
const fixedPriceParams = {
fixedRateAddress: oceanConfig.fixedRateExchangeAddress,
baseTokenAddress: oceanConfig.oceanTokenAddress,
owner: publisherAccount,
marketFeeCollector: publisherAccount,
baseTokenDecimals: 18,
datatokenDecimals: 18,
fixedRate: '1',
marketFee: '0',
allowedConsumer: publisherAccount,
withMint: false
}
const result = await Factory.createNftErc20WithFixedRate(
publisherAccount,
nftParams,
erc20Params,
fixedPriceParams
);
const erc721Address = result.events.NFTCreated.returnValues[0];
const datatokenAddress = result.events.TokenCreated.returnValues[0];
return {
erc721Address,
datatokenAddress
};
};
createDataNFT()
.then(({ erc721Address, datatokenAddress }) => {
console.log(`DataNft address ${erc721Address}`);
console.log(`Datatoken address ${datatokenAddress}`);
process.exit(1);
})
.catch((err) => {
console.error(err);
process.exit(1);
});
teatatokfreicreate_datatoken_with_fre.js
```
{% endcode %}
{% endtab %}
{% tab title="ocean.py" %}
{% code title="create_datatoken_with_fre.py" %}
```python
# Note: Ensure that .env and config.py are correctly setup
from config import web3_wallet, ocean
data_nft = ocean.create_data_nft(
name="NFTToken1",
symbol="NFT1",
from_wallet=web3_wallet,
# Optional parameters
token_uri="https://example.com",
template_index=1,
transferable=True,
owner=web3_wallet.address,
)
print(f"Created dataNFT. Its address is {data_nft.address}")
datatoken = data_nft.create_datatoken("Datatoken 1", "DT1", from_wallet=web3_wallet)
print(f"Created datatoken. Its address is {datatoken.address}")
exchange_id = ocean.create_fixed_rate(
datatoken=datatoken,
base_token=ocean.OCEAN_token,
amount=ocean.to_wei(100),
from_wallet=web3_wallet,
)
print(f"Created fixed rate exchange with ID {exchange_id.hex()}")
```
{% endcode %}
{% endtab %}
{% endtabs %}

View File

@ -0,0 +1,89 @@
# Mint datatoken
#### Configuration
See [this](configuration.md) guide on defining a `.env` file and a configuration file
#### Create a script to mint datatokens
{% tabs %}
{% tab title="ocean.js" %}
{% code title="mint_datatoken.js" %}
```javascript
const { NftFactory, Datatoken } = require('@oceanprotocol/lib');
const Web3 = require('web3');
const { web3Provider, oceanConfig } = require('./config');
const web3 = new Web3(web3Provider);
// Change this
const datatokenAddress = "0xD3542e5F56655fb818F9118CE219e1D10751BC82"
const receiverAddress = "0xBE5449a6A97aD46c8558A3356267Ee5D2731ab5e"
const mintDatatoken = async (datatokenAddress, receiverAddress) => {
const accounts = await web3.eth.getAccounts();
const publisherAccount = accounts[0];
const datatoken = new Datatoken(web3);
let receiverBalance = await datatoken.balance(
datatokenAddress,
receiverAddress
);
console.log(`Receiver balance before mint: ${receiverBalance}`);
await datatoken.mint(
datatokenAddress,
publisherAccount,
'1',
receiverAddress
);
receiverBalance = await datatoken.balance(
datatokenAddress,
receiverAddress
);
console.log(`Receiver balance after mint: ${receiverBalance}`);
};
mintDatatoken(datatokenAddress, receiverAddress)
.then(() => {
process.exit((err) => {
console.error(err);
process.exit(1);
});
})
.catch((err) => {
console.error(err);
process.exit(1);
});
```
{% endcode %}
{% endtab %}
{% tab title="ocean.py" %}
{% code title="mint_datatoken.py" %}
```python
# Note: Ensure that .env and config.py are correctly setup
from config import web3_wallet, ocean
# Change this
datatoken_address = "0xD3542e5F56655fb818F9118CE219e1D10751BC82"
receiver_address = "0xBE5449a6A97aD46c8558A3356267Ee5D2731ab5e"
datatoken = ocean.get_datatoken(datatoken_address)
print(f"Balance before mint: {datatoken.balanceOf(receiver_address)}")
datatoken.mint(
account_address=receiver_address,
value=ocean.to_wei("1"),
from_wallet=web3_wallet,
)
print(f"Balance after mint: {datatoken.balanceOf(receiver_address)}")
nt_d
```
{% endcode %}
{% endtab %}
{% endtabs %}

View File

@ -0,0 +1,17 @@
# Update metadata
#### Configuration
See [this](configuration.md) guide on defining a `.env` file and a configuration file
#### Create a script to update the metadata
{% tabs %}
{% tab title="ocean.js" %}
{% endtab %}
{% tab title="ocean.py" %}
{% endtab %}
{% endtabs %}