
Integrations
Session for the best basic examples of using the Kinera network for d-apps
For this basic example, are use React with Typescript template:
Dependencies:
@polkadot/api
@polkadot/types/interfaces/jsonrpcUse all dependencies for create a basic Api service for chain:
import { ApiPromise, WsProvider } from '@polkadot/api'
import jsonrpc from '@polkadot/types/interfaces/jsonrpc'
import { metadata } from './metadata'Create a a ws provider:
const wsProvider = new WsProvider('wss://node.kinera.network')Sendo types:
const types = metadataCreate a promise:
const api = await ApiPromise.create({
provider: wsProvider,
types,
rpc: jsonrpc,
})Full example:
import { ApiPromise, WsProvider } from '@polkadot/api'
import jsonrpc from '@polkadot/types/interfaces/jsonrpc'
import { metadata } from './metadata'
let curentConn = false
export async function api() {
if (!curentConn) {
curentConn = true
const wsProvider = new WsProvider('wss://node.kinera.network')
const types = metadata
const api = await ApiPromise.create({
provider: wsProvider,
types,
rpc: jsonrpc,
})
return api
}
}
Example usage:

Get Contellation detail by Id:
try {
let request: any = await api.query.festivalModule.festivals(id)
return request?.toHuman()
} catch (err) {
return err
}
{
"id": "25",
"owner": "5H1HeTLYgs12cCzVNHjeoCnr1BgR3XDahDnzcq7BQJ6g8Yt1",
"name": "Which is you favourite Film by Kurosawa?",
"description": "0x4b75726f736177612c2061206d6173746572206f66204a6170616e6573652063696e656d610a",
"status": "Finished",
"maxEntry": "0",
"totalLockup": "164,000,000,000,000",
"voteMap": {
"https://www.youtube.com/watch?v=KiCWrDMZZFk&list=PLJPaUF2U9T-ymgl4gmm6OxPpR60qjOEmO&index=2": [
{
"voter": "5H1HeTLYgs12cCzVNHjeoCnr1BgR3XDahDnzcq7BQJ6g8Yt1",
"amount": "50,000,000,000,000",
"amountAfterWeight": "50,000,000,000,000",
"user": "Hal2001"
}
],
"https://www.youtube.com/watch?v=PMvuqYMg8mw&list=PLrrKbHPKjy_PCXffzEsG8ezpwm2rNXyQm&index=4&t=26s": [
{
"voter": "5H1HeTLYgs12cCzVNHjeoCnr1BgR3XDahDnzcq7BQJ6g8Yt1",
"amount": "2,000,000,000,000",
"amountAfterWeight": "2,000,000,000,000",
"user": "Hal2001"
}
],
"https://www.youtube.com/watch?v=V64AvILWCFA&list=PLrrKbHPKjy_PCXffzEsG8ezpwm2rNXyQm&index=5": [
{
"voter": "5H1HeTLYgs12cCzVNHjeoCnr1BgR3XDahDnzcq7BQJ6g8Yt1",
"amount": "1,000,000,000,000",
"amountAfterWeight": "1,000,000,000,000",
"user": "Hal2001"
}
],
"https://www.youtube.com/watch?v=YKeXb33eE-w": [
{
"voter": "5DPNktjWJU4v4D9SaHNzTtZcpDwFt81MrTn6sWk8JvTeP9vG",
"amount": "111,000,000,000,000",
"amountAfterWeight": "111,000,000,000,000",
"user": "Zyra Veil"
}
]
},
"categoriesAndTags": [
[
"Cinema",
"Drama"
]
],
"internalMovies": [],
"externalMovies": [
"https://www.youtube.com/watch?v=KiCWrDMZZFk&list=PLJPaUF2U9T-ymgl4gmm6OxPpR60qjOEmO&index=2",
"https://www.youtube.com/watch?v=YKeXb33eE-w",
"https://www.youtube.com/watch?v=PMvuqYMg8mw&list=PLrrKbHPKjy_PCXffzEsG8ezpwm2rNXyQm&index=4&t=26s",
"https://www.youtube.com/watch?v=V64AvILWCFA&list=PLrrKbHPKjy_PCXffzEsG8ezpwm2rNXyQm&index=5"
],
"winners": [
"https://www.youtube.com/watch?v=YKeXb33eE-w"
],
"blockStartEnd": [
"25,335",
"169,335"
],
"votePowerDecreaseBlock": "154,935"
}Last updated