Create channel overview
This API is useful for creating a channel, which is the first step for sending a notification on Push Protocol.
Create channel API
Any protocol that wants to send a notification to their users needs to create a channel. A wallet can only have one channel.
- js
// userAlice.channel.create({options})
const response = await userAlice.channel.create({
name: 'Test Channel',
description: 'Test Description',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAz0lEQVR4AcXBsU0EQQyG0e+saWJ7oACiKYDMEZVs6GgSpC2BIhzRwAS0sgk9HKn3gpFOAv3v3V4/3+4U4Z1q5KTy42Ql940qvFONnFSGmCFmiN2+fj7uCBlihpgh1ngwcvKfwjuVIWaIGWKNB+GdauSk8uNkJfeNKryzYogZYoZY40m5b/wlQ8wQM8TayMlKeKcaOVkJ71QjJyuGmCFmiDUe+HFy4VyEd57hx0mV+0ZliBlihlgL71w4FyMnVXhnZeSkiu93qheuDDFDzBD7BcCyMAOfy204AAAAAElFTkSuQmCC',
url: 'https://push.org',
});
Create channel parameters
Param | Type | Subtype | Default | Remarks |
---|---|---|---|---|
options | object | - | - | Configuration options for creating a channel |
- | options.name | string | - | The name of the channel |
- | options.description | string | - | A description of the channel |
- | options.icon | string (base64 encoded) | - | The channel's icon in base64 encoded string format |
- | options.url | string | - | The URL associated with the channel |
- | options.alias | string | - | alias address in in chain specific wallet format |
- | options.progresshook | (progress) => void | - | A callback function that's called during channel creation progress, see progress object |
Note: Parameters
in this style
are mandatory.
Expected response
{
transactionHash: '0x0232fb66e2cb41c291ca10af4aa3ad0bc515adcea34de0f456db10306db89677';
}
Create channel progress object parameters
Optional: Informs about individual progress stages during channel creation if progresshook is function is passed during channel creation API call.
Param | Type | Subtype | Default | Remarks |
---|---|---|---|---|
progress | object | - | - | progress object that is passed in the callback |
- | Progress.id | string | - | Predefined, ID associated with the progress objects |
- | Progress.level | string | - | Predefined, Level associated with the progress objects |
- | Progress.title | string | - | Predefined, title associated with the progress objects |
- | Progress.info | string | - | Predefined, info associated with the progress objects |
Progress object details
Progress.id | Progress.level | Progress.title | Progress.info |
---|---|---|---|
PUSH-CHANNEL-CREATE-01 | INFO | Uploading data to IPFS | The channel’s data is getting uploaded to IPFS |
PUSH-CHANNEL-CREATE-02 | INFO | Approving PUSH tokens | Gives approval to Push Core contract to spend 50 $PUSH |
PUSH-CHANNEL-CREATE-03 | INFO | Channel is getting created | Calls Push Core contract to create your channel |
PUSH-CHANNEL-CREATE-04 | SUCCESS | Channel creation is done, Welcome to Push Ecosystem | Channel creation is completed |
PUSH-CHANNEL-UPDATE-01 | INFO | Uploading new data to IPFS | The channel’s new data is getting uploaded to IPFS |
PUSH-CHANNEL-UPDATE-02 | INFO | Approving PUSH tokens | Gives approval to Push Core contract to spend 50 $PUSH |
PUSH-CHANNEL-UPDATE-03 | INFO | Channel is getting updated | Calls Push Core contract to update your channel details |
PUSH-CHANNEL-UPDATE-04 | SUCCESS | Channel is updated with new data | Channel is successfully updated |
PUSH-ERROR-02 | ERROR | Transaction failed for a function call | Transaction failed |