if (!window.locus) {
alert('Locus wallet is not installed.');
return;
}
const addr = await window.locus.request('connect', {}).catch(err => {
console.error(err);
});
console.error(addr);
window.locus.on('accountChanged', data) => {
console.log(`accountChanged! ${data.addr}`);
}
Connect the wallet to the designated site.
[None]
| Key | Type | Description |
|---|
| - | string | Connected wallet address |
Retrieve the account connected to the target site.
[None]
| Key | Type | Description |
|---|
| - | string | Account Address |
Retrieve the amount of coins held by the account.
| Key | Type | Description |
|---|
| addr | string | Account Address |
| Key | Type | Description |
|---|
| - | string | Amount of coins held |
Retrieve the RPC URL of the selected network.
[None]
| Key | 타Type | Description |
|---|
| - | string | RPC url |
Sign a string with the normal private key.
| Key | Type | Description |
|---|
| input | string | target to Sign |
| Key | Type | Description |
|---|
| - | string | Signature result |
Register a new network in the wallet.
| Key | Type | Description |
|---|
| name | string | Name |
| rpcUrl | string | RPC call url |
| currencySymbol | string | Default currency |
| explorerUrl | string | (Optional) Explorer URL |
| Key | Type | Description |
|---|
| - | boolean | Success Status |
Send coins to another account.
| Key | Type | Description |
|---|
| to | string | Recipient account address |
| amount | string | Quantity of coins to send |
| Key | Type | Description |
|---|
| Hash | base64 | |
| Tx | string | |
| Success | bool | Success Status |
Send tokens to another account.
| Key | Type | Description |
|---|
| contractAddr | string | Contract address |
| to | string | Recipient account address |
| amount | string | Quantity of tokens to send |
| decimal | int32 | Token decimal place |
| Key | Type | Description |
|---|
| Hash | base64 | |
| Tx | string | Generated Tx |
| Success | bool | Success Status |
Create contract.
| Key | Type | Description |
|---|
| contractAccount | string | (Optional) Address for the contract to be created. If not provided, a new address will be generated. |
| code | string | binary code of source |
| amount | string | Coins to be deposited into the newly created contract account, which will be deducted from the creator's coins. |
| fuelLimit | uint32 | Fuel limit for creating the contract. |
| tokenAmounts | []{TokenID base32, AmountToken string} | Token information to be sent to the contract. |
| sysId | base32 | |
| sysType | string | system type |
| until | base32 | Maximum rounds for retrying contract creation. |
| Key | Type | Description |
|---|
| ContractAccount | base32 | The address of the created contract. You can use the return value of the first call as an argument for the second call. |
| Hash | base64 | |
| Tx | string | Generated Tx |
| Success | bool | Success Status |
Execute the contract function.
| Key | Type | Description |
|---|
| contractAccount | string | Smart Contract address |
| func | string | Function name |
| argData | string | Parameters |
| abi | string | ABI JSON string of the function to be executed |
| funcStr | string | (Optional) Function name for display in the wallet |
| funcArgs | []string | (Optional) Parameters for display in the wallet |
| Key | Type | Description |
|---|
| Hash | base64 | |
| Tx | string | Generated Tx |
| Success | bool | Success Status |
Calls a function to read data from the smart contract.
| Key | Type | Description |
|---|
| contractAccount | string | Smart contract address |
| func | string | Function name |
| argData | string | Parameters |
| Key | Type | Description |
|---|
| Result | base64 | Result of the function call |
| Err | string | Error message, if any |
This event occurs once when the wallet is properly installed and ready for use.
| Key | Type | Description |
|---|
| addr | string | Current selected account address |
| connected | boolean | Whether the account is connected to the site |
| extensionId | string | Wallet's extension ID |
| network | network | Selected network information |
network
| Key | Type | Description |
|---|
| id | string | Network ID |
| name | string | Network name |
| rpcUrl | string | RPC URL |
| currencySymbol | string | Currency symbol |
| explorerUrl | string | Explorer URL |
Occurs when the wallet is connected to the target site.
| Key | Type | Description |
|---|
| addr | string | Connected account address |
Occurs when the wallet is disconnected from the target site.
| 키Key | Type | Description |
|---|
| addr | string | Disconnected account address |
Occurs when the account is changed.
| Key | Type | Description |
|---|
| addr | string | Account Address |
Occurs when the network is changed.
| Key | Type | Description |
|---|
| id | string | Network ID of the registered network |
| name | string | Name of the registered network |
| rpcUrl | string | RPC URL for the registered network |
| currencySymbol | string | Default currency symbol for the registered network |
| explorerUrl | string | Explorer URL for the registered network |
Occurs when logging out from the wallet.
[None]
Occurs when logging into the wallet.
| Key | Type | Description |
|---|
| addr | string | Address of the logged-in account |
Occurs when accepting the wallet confirmation prompt.
| Key | Type | Description |
|---|
| uuid | string | Request unique key |
| data | string | Execution result |
Occurs when rejecting the wallet confirmation prompt.
| Key | Type | Description |
|---|
| uuid | string | Request unique key |
| code | string | 0: General 1: Rejected by user |
| message | string | Error Message |
Occurs when all requests are rejected in the wallet confirmation prompt.
| Key | Type | Description |
|---|
| - | []result | List of rejected requests |
result
| Key | Type | Description |
|---|
| uuid | string | Request unique key |
| code | string | 0: General 1: Rejected by user |
| message | string | Error Message |