Skip to main content

Methods

info

dapp provider has the following methods.

1. dapp:accounts

This method is used to request a wallet connection. A website can use this function to request a connection to your wallet, and if the user in the wallet approves the connection, the website can access your account. This approach asks for connections to all chains at the same time. In other words, if you make a request with ethereum in chainName, you will be granted access to the cosmos or other networks. If the webpage is already linked to your wallet, it imports the information from your account without asking for your additional authorization.

Params

The method takes the following input argument as a chainName.

type ChainName = 'celo' | 'cosmos' | 'ethereum' | 'klaytn' | 'near' | 'neon' | 'solana';

window.dapp.request(chainName: ChainName, { method: "dapp:accounts" })

Returns

The method returns the promise object with an address and pubKey value with the given chain account. WELLDONE Wallet currently only supports one address/public key pair per chainID

{ "ethereum": { "address": "0x....", "pubKey": "0x...." } }

Example

This example is to query the account information of Ethereum from your WELLDONE Wallet.

Live Editor
Result
Loading...

2. dapp:addChain

This method is to be utilized when adding other networks on the WELLDONE wallet. For the earlier release of WELLDONE wallet, it supports Ethereum, Cosmos and Solana. We are planning to support more networks for future releases.

tip

WELLDONE Studio operates AddChain to add networks to your wallet, as well as the directly using dapp:addChain method. More details may be found here.

Params

The method takes chainName and chainData that designates the network that you are going to add. See more information that you are required to pass on params for the following sections.

type ChainName = 'cosmos' | 'ethereum' | 'solana';

await dapp.request(chainName: ChainName, (
method: "dapp:addChain",
params: [chainData]
))

Example

The following is a simple example that adds Ubiq network that is EVM compatible.

Live Editor
Result
Loading...

3. dapp:sendTransaction

This is the method that sends the transaction. From simple token transfer to contract distribution and change the state of the blockchain, this method can be used. The WELLDONE Wallet finds and imports networks associated with that wallet address. Before submitting a transaction, you should evaluate whether to transmit it to the mainnet or the testnet.

Params

CHAIN NAME and TRANSACTION_PARAMETER are two parameters. CHAIN_NAME is the name of the network to which you wish to add, and TRANSACTION_PARAMETER is the value of converting the transaction to a string type. Because a transaction format differs by networks, WELLDONE Wallet executes the transaction by taking the input argument in string type then translate it to compatible to the targeted network.

type CHAIN_NAME = 'ethereum' | 'cosmos' | 'near' | 'solana' | 'klaytn' | 'celo' | 'neon';
type TRANSACTION_PARAMETER = 'string';

const response = await dapp.request(CHAIN_NAME, {
method: 'dapp:sendTransaction',
params: [TRANSACTION_PARAMETER],
});

The following sections for each network provide details of what needs to be communicated to the TRANSACTION_PARAMETER.

Returns

This method returns the transaction hash value as a Promise object of type string.

Promise<string[]>;

Example

The following is an example of sending a transaction on Ethereum network. A faucet is required to transmit a transaction. The following URL will send you a tap of the Ethereum Ropsten testnet token.

Live Editor
Result
Loading...

4. dapp:getBalance

This method returns the balance of the address.

Params

This method takes the network and account information to query balance as an argument.

type CHAIN_NAME = 'ethereum' | 'cosmos' | 'near' | 'solana' | 'klaytn' | 'celo' | 'neon';
type ACCOUNTS = string;

const response = await dapp.request(CHAIN_NAME, {
method: 'dapp:getBalance',
params: [ACCOUNTS],
});
const txHash = response.hash;

Returns

The return value is differed from the networks that you are going to access.

  • ethereum, klaytn, celo, neon, near, solana

    Promise<string>;
  • cosmos

    Promise<[{ ammout: string; denom: string }]>;

Example

This example is to query balance from the Ethereum account.

Live Editor
Result
Loading...

5. dapp:sign

This is the method for signing messages. This method allows you to sign messages or transactions.

Params

The method takes the name of the chain CHAIN_NAME and the message MESSAGE you want to sign as parameters in string type. Because a sign message format differs by the network, WELLDONE Wallet takes the input message in string type and then translates it to be compatible with the targeted network.

type CHAIN_NAME = 'near';
type MESSAGE = string;

const response = await dapp.request(CHAIN_NAME, {
method: 'dapp:sign',
params: [MESSAGE],
});
info

The dapp:sign method currently supports only the NEAR chain. We'll support the method in other chains in the future.

Returns

The method returns the signature value that signed the message and the publicKey used for signing as a string type Promise object.

Promise<{ signature: string; publicKey: string }>;

Example

The following is an example of a signing message and transaction in NEAR.

Live Editor
Result
Loading...