Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Ocean.js-PlayGround/1.2.3.mintDatatoken.js /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
48 lines (38 sloc)
1.16 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { NftFactory, Datatoken } = require('@oceanprotocol/lib'); | |
| const Web3 = require('web3'); | |
| const { web3Provider, oceanConfig } = require('./config'); | |
| const web3 = new Web3(web3Provider); | |
| 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}`); | |
| }; | |
| const datatokenAddress = "0xD3542e5F56655fb818F9118CE219e1D10751BC82" | |
| const receiverAddress = "0xBE5449a6A97aD46c8558A3356267Ee5D2731ab5e" | |
| mintDatatoken(datatokenAddress, receiverAddress) | |
| .then(() => { | |
| process.exit((err) => { | |
| console.error(err); | |
| process.exit(1); | |
| }); | |
| }) | |
| .catch((err) => { | |
| console.error(err); | |
| process.exit(1); | |
| }); | |