-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0df5f3
commit 5d884ca
Showing
4 changed files
with
107 additions
and
9 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
.snippets/code/builders/substrate/interfaces/features/randomness/local-vrf-output.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
// Initialize the API | ||
const api = await ApiPromise.create({ | ||
provider: new WsProvider('wss://moonbase-alpha.public.blastapi.io') | ||
}); | ||
|
||
try { | ||
// Get the local VRF output from randomness pallet | ||
const localVrf = await api.query.randomness.localVrfOutput(); | ||
|
||
console.log('Local VRF Output:', localVrf.toString()); | ||
|
||
process.exit(0); | ||
} catch (error) { | ||
console.error('Error querying local VRF output:', error); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
// Execute the script | ||
main().catch(error => { | ||
console.error('Script error:', error); | ||
process.exit(1); | ||
}); |
26 changes: 26 additions & 0 deletions
26
.snippets/code/builders/substrate/interfaces/features/randomness/pallet-version.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
// Initialize the API | ||
const api = await ApiPromise.create({ | ||
provider: new WsProvider('wss://moonbase-alpha.public.blastapi.io') | ||
}); | ||
|
||
try { | ||
// Get the pallet version from randomness pallet | ||
const version = await api.query.randomness.palletVersion(); | ||
|
||
console.log('Randomness Pallet Version:', version.toString()); | ||
|
||
process.exit(0); | ||
} catch (error) { | ||
console.error('Error querying randomness pallet version:', error); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
// Execute the script | ||
main().catch(error => { | ||
console.error('Script error:', error); | ||
process.exit(1); | ||
}); |
40 changes: 40 additions & 0 deletions
40
.snippets/code/builders/substrate/interfaces/features/randomness/randomness-results.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
// Initialize the API | ||
const api = await ApiPromise.create({ | ||
provider: new WsProvider('wss://moonbase-alpha.public.blastapi.io') | ||
}); | ||
|
||
try { | ||
// Query Babe Epoch randomness results | ||
const babeResults = await api.query.randomness.randomnessResults({ BabeEpoch: 0 }); | ||
console.log('\nBabe Epoch Randomness Results:'); | ||
console.log(babeResults.toHuman()); | ||
|
||
// Query Local randomness results | ||
const localResults = await api.query.randomness.randomnessResults({ Local: 0 }); | ||
console.log('\nLocal Randomness Results:'); | ||
console.log(localResults.toHuman()); | ||
|
||
// Get the available keys/entries | ||
console.log('\nAll Available Randomness Results:'); | ||
const entries = await api.query.randomness.randomnessResults.entries(); | ||
entries.forEach(([key, value]) => { | ||
console.log('Key:', key.args.map((k) => k.toHuman())); | ||
console.log('Value:', value.toHuman()); | ||
console.log('---'); | ||
}); | ||
|
||
process.exit(0); | ||
} catch (error) { | ||
console.error('Error querying randomness results:', error); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
// Execute the script | ||
main().catch(error => { | ||
console.error('Script error:', error); | ||
process.exit(1); | ||
}); |
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