Skip to content

Build on Magi

This page contains the resources you need to build your application on Magi.

The Magi GraphQL API can be used to retrieve various kinds of information about the Magi network. It is the core building block when it comes to creating applications on top of Magi.

The documentation may be found in the GraphQL sandbox accessible through Magi nodes.

API endpointOperatorSandbox
https://api.vsc.eco/api/v1/graphqlMagi TeamSandbox
https://vsc.techcoderx.com/api/v1/graphql@techcoderxSandbox
https://vsc.atexoras.com:2087/api/v1/graphql@forkyishereSandbox

Magi JS is JavaScript/TypeScript library for interacting with Magi with wallet interoperability features.

It may be installed through NPM:

Terminal window
pnpm i @aioha/magi @aioha/aioha viem
import { Magi, Wallet, Asset } from '@aioha/magi'
import { createWalletClient, http } from 'viem'
import { initAioha } from '@aioha/aioha'
const magi = new Magi()
// Set options
magi.setApi('https://magi-test.techcoderx.com/api/v1/graphql', [])
magi.setNetId('vsc-testnet')
// Ethereum wallet
const viemClient = createWalletClient({
account: '0x2540009A1027e5c6aa0274db4fEF2622aC2B200C',
transport: http('http://127.0.0.1:1248')
})
magi.setViem(viemClient)
// Hive wallet
const aioha = initAioha()
magi.setAioha(aioha)
// Set wallet type to use
magi.setWallet(Wallet.Ethereum)
// Transfer 1 HBD
const xfer = await magi.transfer('did:pkh:eip155:1:0xrecipient', 1, Asset.hbd, '')
// Call contract
const dumpEnv = await magi.call('vsc1contractid', 'method', 'payload', 200, [])
// Sign and broadcast multi-op transaction
const call = await magi.signAndBroadcastTx([
{
type: 'call',
payload: {
contract_id: 'vsc1BX9RbKJYAqSSZZzrGeBWyBZkG3ojTVPRoo',
action: 'dumpEnv',
payload: '',
rc_limit: 300,
intents: []
}
}
])

This library is part of Aioha. Refer to the docs here for more usage details.