Paras Documentation v2
  • Overview
  • Contract
  • Getting Started
  • Using near-api-js
  • NFT contract function calls
    • Creating new NFT series
    • NFT series functions
    • NFT functions
  • Marketplace contract function calls
    • Marketplace functions
  • NFT smart contract integration
  • NFT Metadata
  • Reference
    • API Reference
  • Examples
Powered by GitBook
On this page

Getting Started

Authentication

You will need authentication to Paras if you want to:

  1. Create a publication

  2. Edit collection

  3. Create collections

  4. Edit collections

  5. Upload files

All direct function call to the smart contract would authentication with the near blockchain. To generate auth token please look at the following script,

const nearAPI = require('near-api-js')
const { Base64 } = require('js-base64')

const authToken = async (accountId, signer, networkId) => {
	try {
		const arr = new Array(accountId)
		for (var i = 0; i < accountId.length; i++) {
			arr[i] = accountId.charCodeAt(i)
		}
		const msgBuf = new Uint8Array(arr)
		const signedMsg = await signer.signMessage(
			msgBuf,
			accountId,
			networkId
		)
		const pubKey = Buffer.from(signedMsg.publicKey.data).toString('hex')
		const signature = Buffer.from(signedMsg.signature).toString('hex')
		const payload = [accountId, pubKey, signature]
		return Base64.encode(payload.join('&'))
	} catch (err) {
		console.log(err)
		return null
	}
}

const main = async () => {
	const config = {
		networkId: 'testnet',
		nodeUrl: 'https://rpc.testnet.near.org',
		walletUrl: 'https://wallet.testnet.near.org',
		appName: 'Paras Testnet',
		contractName: `paras-token-v2.testnet`
	}

	try {
		// Initializing nearAPI
		// Login and init contract
		const keyStore = new nearAPI.keyStores.UnencryptedFileSystemKeyStore(
			`${process.env.HOME}/.near-credentials/`
		)

		const signer = new nearAPI.InMemorySigner(keyStore)

		const connection = await nearAPI.connect({
			deps: {
				keyStore: keyStore,
			},
			...config,
		})

		const account_id = 'orang.testnet'
		const account = await connection.account(account_id)
		const authorizationHeader = await authToken(account_id, signer, config.networkId)

		console.log(`Authorization Header : ${authorizationHeader}`)
	} catch (err) {
		throw err
	}
}

main()

Essential projects

We have two main smart contracts,

  1. NFT contract (x.paras.near) -- serves all the NFT created on Paras. this is where NFT will be minted from the creator

  2. Marketplace (marketplace.paras.near) -- secondary market, this is where buy and sale single NFT happens

Repository
Details

Frontend

Marketplace contract

NFT contract

PreviousContractNextUsing near-api-js

Last updated 3 years ago

https://github.com/parasHQ/paras-landing
https://github.com/ParasHQ/paras-marketplace-contract
https://github.com/parasHQ/paras-nft-contract/