example.js 761 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const { RuntimeApi } = require('@joystream/storage-runtime-api')
  2. const { discover, publish } = require('./')
  3. async function main() {
  4. // The assigned storage-provider id
  5. const provider_id = 0
  6. const runtimeApi = await RuntimeApi.create({
  7. // Path to the role account key file of the provider
  8. account_file: '/path/to/role_account_key_file.json',
  9. storageProviderId: provider_id,
  10. })
  11. const ipns_id = await publish.publish(
  12. {
  13. asset: {
  14. version: 1,
  15. endpoint: 'http://endpoint.com',
  16. },
  17. },
  18. runtimeApi
  19. )
  20. console.log(ipns_id)
  21. // register ipns_id on chain
  22. await runtimeApi.setAccountInfo(ipfs_id)
  23. const serviceInfo = await discover.discover(provider_id, runtimeApi)
  24. console.log(serviceInfo)
  25. runtimeApi.api.disconnect()
  26. }
  27. main()