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);
const params = {
assetType: 'asset1',
amount: '1000',
operator: '',
metaData: await window.locus.utils.ConvertStringToData(
'{"imageUrl":"https://foo/test.png"}'
)
};
const result = await window.locus.request('createAssetObject', params).catch(err => {
console.error(err);
});
console.log('createAssetObject result', result);
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 |
계정의 상태를 조회합니다.
[없음]
| 키 | 타입 | 설명 |
|---|
| status | string | 계정 상태 (pending: 오픈어카운트가 완료되지 않은 상태, activated: 오픈어카운트가 완료된 상태) |
| info | object | locus_getAccountDetail rpc 응답값 Locus JSON-RPC |
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 | |
| 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 |
AssetObject 를 생성 한다.
| 키 | 타입 | 설명 |
|---|
| assetType | string | 생성할 객체의 형식 |
| amount | string | 생성할 수량 , 0 으로 설정시 수량이 없는 단일 Object 로 생성 |
| operator | string | 관리 계정 (Contract 주소) |
| metaData | base64 | 사용자 지정하는 형식의 정보 데이타 |
AssetObject 를 전송한다.
| 키 | 타입 | 설명 |
|---|
| to | base32 | Asset 객체를 받을 계정 |
| assetId | base64 | Asset 의 고유 ID |
| amount | string | 수량 |
계정의 Asset 목록을 조회하여 AssetId 별로 Object ID 와 수량을 조회 한다.
| 키 | 타입 | 설명 |
|---|
| count | number | 가져올 갯수 제한치, 0 이면 전부 |
| 키 | 타입 | 설명 |
|---|
| AssetList | string | 보유한 객체 정보 배열 (통합수량, ObjectId 배열) []{Amount, []Digest} |
계정에서 지정한 AssetId 에 해당하는 AssetObject 들을 출력 한다.
| 키 | 타입 | 설명 |
|---|
| AssetId | []base64 | Asset 의 고유 ID의 배열 |
| 키 | 타입 | 설명 |
|---|
| Objects | []AssetObject | 보유한 객체 정보 |
AssetObject
| 키 | 타입 | 설명 |
|---|
| Version | number | 이 객체구조의 버전 |
| Type | string | 객체 타입명 |
| AssetId | string | 객체 타입에 대한 고유 ID |
| ObjectId | string | 객체의 고유 ID |
| Amount | string | 수량 (수량이 0 이면 객체 자체가 단 1 개만 존재) |
| Operator | string | 객체 생성 또는 관리시 연계할 주소 (컨트랙트 연동 주소) |
| MetaData | base64 | 이 객체에 대한 기타 정보들 (사용자 정의) |
| Hash | string | 객체의 유효함을 확인하기 위한 Hash |
This event occurs once when the wallet is properly installed and ready for use.
| Key | Type | Description |
|---|
| connectedAccount | account | 연결된 계정 정보 |
| address | string | Current selected account address |
| network | network | 선택된 네트워크 정보 |
| extensionId | string | Wallet's extension ID |
| connected | boolean | Whether the account is connected to the site |
network
| Key | Type | Description |
|---|
| id | string | Network ID |
| name | string | Network name |
| rpcUrl | string | RPC URL |
| currencySymbol | string | Currency symbol |
| explorerUrl | string | Explorer URL |
account
| 키 | 타입 | 설명 |
|---|
| addr | string | 계정 주소 |
| name | string | 계정 이름 |
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 |
계정이 선택 되었을 때 발생합니다.
| 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 |