2

Context:

I'm trying to fetch datas from an ended crowdloan. The crowdloan is on kusama, for parachain id 2113.

I first connect:

async function connect() {
    let endpoint = config.endpoint;
        global.endpoint = endpoint;
        const provider = new WsProvider(endpoint);
        const api = await ApiPromise.create({
            provider,
            ...spec
        });
        return api;
}

then fetch the addresses of the users that contributed:

async function fetchCrowdloan() {
    try {
        const api = await connect();

        console.log(await api.derive.crowdloan.contributions(2113))
        process.exit(0)
        // other stuff
    } catch (error) {
        console.log(error)
        process.exit(1)
    }
}

Yesterday, when i ran my script, an array of the 478 users i expected to be here, was logged in the terminal. I closed my PC, went to sleep, and this morning, it doesn't work anymore, I get this error:

2022-06-23 12:27:51        RPC-CORE: getKeysPaged(childKey: PrefixedStorageKey, prefix: StorageKey, count: u32, startKey?: StorageKey, at?: Hash): Vec<StorageKey>:: creat
eType(StorageKey):: Expected hex value to convert, found '0x'
2022-06-23 12:27:51             DRR: createType(StorageKey):: Expected hex value to convert, found '0x'
Error: createType(StorageKey):: Expected hex value to convert, found '0x'
    at createTypeUnsafe (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/types-create/cjs/create/type.js:73:18)
    at TypeRegistry.createTypeUnsafe (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/types/cjs/create/registry.js:333:46)
    at /home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/rpc-core/cjs/bundle.js:395:50
    at Array.map (<anonymous>)
    at RpcCore._formatInputs (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/rpc-core/cjs/bundle.js:395:19)
    at callWithRegistry (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/rpc-core/cjs/bundle.js:252:27)
    at Observable._subscribe (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/rpc-core/cjs/bundle.js:266:9)
    at Observable._trySubscribe (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/rxjs/dist/cjs/internal/Observable.js:41:25)
    at /home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/rxjs/dist/cjs/internal/Observable.js:35:31
    at Object.errorContext (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/rxjs/dist/cjs/internal/util/errorContext.js:22:9)

Was there an update in the api of kusama in the night ? How can i solve it ?

Update: all of the other calls are working fine, it's really just the contribution()function

2 Answers 2

1

It was identified as a bug.

See:

There is nothing wrong on your side. Wait for the fix to land and upgrade your @polkadot/api to a newer version.

1
  • Yep, i ended up asking on github, i'm glad they solved it so fast !
    – Erudyx
    Jun 27 at 9:06
0

Works fine for me ("@polkadot/api": "^8.8.3-9"):

import { ApiPromise, WsProvider } from '@polkadot/api';

export const fetchCrowdloan = async () => {
    const wsProvider = new WsProvider('wss://kusama-rpc.polkadot.io');
    const api = await ApiPromise.create({ provider: wsProvider });
    console.log(await api.derive.crowdloan.contributions(2113))
    console.log((await api.derive.crowdloan.contributions(2113)).contributorsHex.length)
}

Output:

{
  blockHash: '-',
  contributorsHex: [
    '0x0034622b3c63b574024d395c25c8e516c0b5d2761d0601d2545cc76f17435801',
    '0x020fa85efa96a432e05598df7ec297921a457cf8a2a7600b92760939d9b9400d',
    ....
  ]
}
478
4
  • I still have the same error using your code, your version and your endpoint... What env are you using ? How do you install/start the script ?
    – Erudyx
    Jun 24 at 8:58
  • install the packages and run the script*
    – Erudyx
    Jun 24 at 13:16
  • or maybe its a yarn version thing Jun 24 at 14:52
  • Bruno what versions are you using? I am getting same problem as erudyx, maybe because i am adding fetchCrowdloan() to call the function, perhaps i need to await or i am calling it incorrectly? Jun 24 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.