v 3.x.x
Search
K
Links
Comment on page

Migrating from aleph-js

We're slowly rolling out the aleph-js package, here are the main differences between both implementation.
While the Typescript SDK and the aleph-js follow the same global patterns here are some of the notable differences.

Naming convention

All the the methods related to messages and accounts are PascalCase (camel case, with a leading uppercase)

Example 1: Creating an account

aleph-js
aleph-sdk-ts
import { ethereum } from 'aleph-js'
const { account } = await ethereum.new_account()
import { ethereum } from 'aleph-sdk-ts/dist/accounts'
const { account } = await ethereum.NewAccount()

Example 2: Publish a Post message

Using the ethereum we created in the previous example we can now send a post message.
aleph-js
aleph-sdk-ts
import { posts } from 'aleph-js'
await posts.submit(
account.address,
'mytype',
{ body: 'test' },
{
account: account,
channel: 'TEST',
api_server: 'https://api2.aleph.im'
}
)
import { post } from 'aleph-sdk-ts/'
await post.Publish({
APIServer: 'https://api2.aleph.im',
channel: 'TEST',
inlineRequested: true,
storageEngine: ItemType.inline,
account: account,
postType: 'mytype',
content: content,
});