Mokhtar Naamani aaeb89561a add @polkadot/metadata to package.json resolutions and rebuild augment types | 3 anos atrás | |
---|---|---|
.. | ||
augment | 3 anos atrás | |
augment-codec | 3 anos atrás | |
src | 3 anos atrás | |
.eslintignore | 4 anos atrás | |
.eslintrc.js | 4 anos atrás | |
.gitignore | 4 anos atrás | |
.npmignore | 4 anos atrás | |
.prettierignore | 4 anos atrás | |
README.md | 3 anos atrás | |
package.json | 3 anos atrás | |
tsconfig-augment-codec.json | 4 anos atrás | |
tsconfig-augment.json | 4 anos atrás | |
tsconfig-base.json | 4 anos atrás | |
tsconfig.json | 4 anos atrás |
@joystream/types
The types package is required to register the custom Substrate runtime types when working with @polkadot/api
to communicate with a Joystream full node.
Add the package as a dependency in your project.
yarn add @joystream/types
# or
npm install --save @joystream/types
import { types } from '@joystream/types'
import { ApiPromise, WsProvider } from '@polkadot/api'
async function main() {
// Initialise the provider to connect to the local node
const provider = new WsProvider('ws://127.0.0.1:9944')
// Create the API and wait until ready
const api = await ApiPromise.create({ provider, types })
// Retrieve the chain & node information information via rpc calls
const [chain, nodeName, nodeVersion] = await Promise.all([
api.rpc.system.chain(),
api.rpc.system.name(),
api.rpc.system.version(),
])
console.log(`Chain ${chain} using ${nodeName} v${nodeVersion}`)
}
main()