Signer
Overview
Waves Signer is a TypeScript/JavaScript library that features signing and broadcasting transactions on behalf of users without asking them for their seed phrases or private keys.
Provider
In order to work with Signer, you need to link an external Provider library. Provider securely stores user's private data. Your web app and Signer itself do not have access to user's private key and seed phrase.
The Provider authenticates user and generates a digital signature.
Signer implements developer-friendly protocol for interacting with Provider as well as broadcasts transactions to the blockchain.

For now, you can use one of the following Providers:
- ProviderSeed developed by Waves team creates user account from SEED. ProviderSeed can be used at the app debugging stage.
- ProviderWeb developed by Waves.Exchange team uses an account created or imported into the Waves.Exchange web app via user's private key or seed phrase.
- ProviderCloud developed by Waves.Exchange team uses an email-based Waves.Exchange.
You can also develop your own Provider, see the Provider Interface section below.
Signer + ProviderWeb: How It Works
When Signer requests to sign a transaction, ProviderWeb opens an iframe, where the user can review transaction details and confirm or reject it. Upon confirmation, ProviderWeb generates a digital signature.
Restrictions
Signer supports all types of transactions except Exchange transaction and Update Asset Info transaction.
Signer supports all browsers except Brave.
Getting Started
1. Signer and Provider library installation
To install Signer library use
npm i @waves/signer
To install ProviderSeed developed by Waves team, use
npm i @waves/provider-seed @waves/waves-transactions
To install ProviderWeb developed by Waves.Exchange, use
npm i @waves.exchange/provider-web
For Windows, use the following format:
npm i '@waves.exchange/provider-web'
To install ProviderCloud developed by Waves.Exchange, use
npm i @waves.exchange/provider-cloud
For Windows, use the following format:
npm i '@waves.exchange/provider-cloud'
2. Library initialization
Add library initialization to your app.
For Testnet & ProviderSeed:
import { Signer } from '@waves/signer';
import { ProviderSeed } from '@waves/provider-seed';
import { libs } from '@waves/waves-transactions';
const seed = libs.crypto.randomSeed(15);
const signer = new Signer({
// Specify URL of the node on Testnet
NODE_URL: 'https://nodes-testnet.wavesnodes.com'
});
signer.setProvider(new ProviderSeed(seed));
For Testnet & Waves.Exchange ProviderWeb:
import { Signer } from '@waves/signer';
import { ProviderWeb } from '@waves.exchange/provider-web';
const signer = new Signer({
// Specify URL of the node on Testnet
NODE_URL: 'https://nodes-testnet.wavesnodes.com'
});
signer.setProvider(new ProviderWeb('https://testnet.waves.exchange/signer/'))
For Testnet & Waves.Exchange ProviderCloud:
import { Signer } from '@waves/signer';
import { ProviderCloud } from '@waves.exchange/provider-cloud';
const signer = new Signer({
// Specify URL of the node on Testnet
NODE_URL: 'https://nodes-testnet.wavesnodes.com'
});
signer.setProvider(new ProviderCloud('https://testnet.waves.exchange/signer/'))
For Mainnet & Waves.Exchange ProviderWeb:
import { Signer } from '@waves/signer';
import { ProviderWeb } from '@waves.exchange/provider-web';
const signer = new Signer();
signer.setProvider(new ProviderWeb());
For Mainnet & Waves.Exchange ProviderCloud:
import { Signer } from '@waves/signer';
import { ProviderCloud } from '@waves.exchange/provider-cloud';
const signer = new Signer();
signer.setProvider(new ProviderCloud());
After that you will be able to use Signer features in the app.
3. Basic example
Now your application is ready to work with Waves blockchain. Let's test it by implementing basic functionality. For example, we could try to authenticate user, get his/her balances and transfer funds.
const user = await signer.login();
const balances = await signer.getBalance();
const [broadcastedTransfer] = await signer
.transfer({amount: 100000000, recipient: 'alias:T:merry'}) // Transfer 1 WAVES to alias merry
.broadcast(); // Promise will resolved after user sign and node response
const [signedTransfer] = await signer
.transfer({amount: 100000000, recipient: 'alias:T:merry'}) // Transfer 1 WAVES to alias merry
.sign(); // Promise will resolved after user sign
More examples
See example of an app that implements the donate button: https://github.com/vlzhr/crypto-donate.
Constructor
new Signer({
NODE_URL: 'string',
})
Creates an object that features the following methods.
Parameters:
Methods
In code you can use TypeScript types.
User Info
login
Authenticates user with his/her account; creates account if it don't exist.
login();
Returns:
Promise of user data: address and public key.
Usage:
const {address, publicKey} = await signer.login();
Output example:
{
address: '3P8pGyzZL9AUuFs9YRYPDV3vm73T48ptZxs',
publicKey: 'FuChbN7t3gvW5esgARFytKNVuHSCZpXSYf1y3eDSruEN',
}
logout
Logs user out.
logout();
Returns: Promise<void>.
Usage:
await signer.logout();
getBalance
If user logged in, provides balances of assets in user's portfolio.
getBalance();
Returns: Promise of list of balances.
Usage:
const balances = await signer.getBalance();
Output example:
[{
assetId: 'WAVES',
assetName: 'Waves',
decimals: 8,
amount: 100000000,
isMyAsset: false,
tokens: 1,
sponsorship: null,
isSmart: false
},
{
assetId: 'AcrRM9STdBu5PNiFveTCbRFTS8tADhKcsbC2KBp8A4tx',
assetName: 'CoffeeCoin',
decimals: 3,
amount: 1500,
isMyAsset: false,
tokens: 1.5,
isSmart: false,
sponsorship: 500
}]
Output fields:
| Field name |
Description |
| assetId |
Base58 encoded ID of the asset |
| assetName |
Name of the asset |
| decimals |
Number of decimal places in the asset amount |
| amount |
Amount of asset multiplied by 10^decimals. For example, decimals of WAVES is 8, so the real amount is multipied by 10^8. { "WAVES": 677728840 } means 6.77728840 |
| isMyAsset |
true if current user is an asset issuer |
| tokens |
Amount of asset to display in app interface |
| sponsorship |
Amount of sponsored asset to be charged to users (per 0.001 WAVES) multiplied by 10^decimals
null if the asset is not sponsored |
| isSmart |
true for smart assets |
getSponsoredBalances
If user logged in, provides balances of sponsored assets in user's portfolio. See Sponsored Fee.
getSponsoredBalances();
Returns: Promise of list of balances.
Usage:
const sponsoredBalances = await signer.getSponsoredBalances();
Output example:
[{
assetId: 'AcrRM9STdBu5PNiFveTCbRFTS8tADhKcsbC2KBp8A4tx',
assetName: 'CoffeeCoin',
decimals: 3,
amount: 1500,
isMyAsset: false,
tokens: 1.5,
isSmart: false,
sponsorship: 500
}]
Output fields are the same as in getBalance method.
Create transactions
The following methods create transactions (but do not sign or broadcast them):
Check which of these transactions are supported by your Provider.
Common fields
Each create transaction method has optional fields that you don't specify manually in most cases:
| Field name |
Description |
Default value |
| chainId |
'W'.charCodeAt(0) or 87 means Mainnet 'T'.charCodeAt(0) or 84 means Testnet |
Defined by configuration of Waves node that is set in Constructor |
| fee |
Transaction fee |
Calculated automatically as described in Transaction fee section |
| proofs |
Array of transaction signatures |
Added by sign or broadcast method (see How to Sign and Broadcast Transactions). If you specify a proof manually, it is also added to the array |
| senderPublicKey |
Base58 encoded public key of transaction sender |
Returned by login method |
How to Sign and Broadcast Transactions
Each create transaction method returns object that features the sign and broadcast methods.
To sign transaction use sign method. For example:
signer.invoke({
dApp: address,
call: { function: name, args: convertedArgs },
}).sign();
To sign transaction and immediately send it to blockchain use broadcast method. For example:
signer.invoke({
dApp: address,
call: { function: name, args: convertedArgs },
}).broadcast();
Note: this broadcast method has the same options as the signer.broadcast method that is described below.
You can sign or broadcast several transactions at once. For example:
signer.alias({ 'new_alias', })
.data([{ key: 'value', type: 'integer', value: 1 ])
.transfer({ recipient: '3P8pGyzZL9AUuFs9YRYPDV3vm73T48ptZxs', amount: 10000 })
}).broadcast();
alias
Creates Create Alias transaction.
alias(data: {
alias: 'string'
})
Parameters:
| Parameter name |
Default value |
Description |