Skip to content

Commit 797b6ef

Browse files
authored
Merge pull request #86 from FidelVe/update-contract-example-to-java
Update token deployment example
2 parents f3f26c8 + 54c56bc commit 797b6ef

File tree

4 files changed

+94
-90
lines changed

4 files changed

+94
-90
lines changed

quickstart/README.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ If you want to use custom ICON node url, change the value of `NODE_URL` variable
5050
*For more information on the testnet, see [the documentation](https://github.com/icon-project/icon-project.github.io/blob/master/docs/icon_network.md) for the ICON network.*
5151

5252
```javascript
53-
const NODE_URL = 'https://bicon.net.solidwallet.io/api/v3';
53+
const NODE_URL = 'https://bicon.net.solidwallet.io/api/v3';
5454
```
5555

5656

@@ -122,7 +122,7 @@ After calling `store`, Keystore json object can be looked up with the returned v
122122
const privateKey = '38f792b95a5202ab431bfc799f7e1e5c74ec0b9ede5c6142ee7364f2c84d72f6'
123123
const wallet = IconWallet.loadPrivateKey(privateKey);
124124
console.log(wallet.store('qwer1234!'));
125-
// Output:
125+
// Output:
126126
// {
127127
// "version": 3,
128128
// "id": "e00e113c-1e45-47e4-b732-10f3d1903d75",
@@ -225,7 +225,7 @@ Generate SignedTransaction to add signature of the transaction.
225225
const signedTransaction = new SignedTransaction(transaction, wallet);
226226
// Read params to transfer to nodes
227227
console.log(signedTransaction.getProperties());
228-
// Output:
228+
// Output:
229229
// {
230230
// from: "hx902ecb51c109183ace539f247b4ea1347fbf23b5",
231231
// nid: "0x3",
@@ -294,7 +294,7 @@ const wallet = IconWallet.loadPrivateKey(MockData.PRIVATE_KEY_2);
294294
const balance = await iconService.getBalance(wallet.getAddress()).execute();
295295
console.log(balance);
296296

297-
// Output:
297+
// Output:
298298
// 100432143214321432143
299299
```
300300

@@ -308,18 +308,18 @@ This example shows how to deploy IRC token and transfer deployed token.
308308

309309
You need the SCORE Project to deploy token.
310310

311-
In this example, you will use ‘test.zi’ from the ‘resources’ folder.
311+
In this example, you will use ‘irc2-token.jar’ from the ‘resources’ folder.
312312

313-
*test.zi : SampleToken SCORE Project Zip file.
313+
*irc2-token.jar : SampleToken SCORE contract.
314314

315-
Generate wallet using `MockData.PRIVATE_KEY_1`, then read the binary data from ‘test.zi
315+
Generate wallet using `MockData.PRIVATE_KEY_1`, then read the binary data from ‘irc2-token.jar
316316

317317
```javascript
318318
const { Wallet } = this.iconService;
319319
this.wallet = IconWallet.loadPrivateKey(MockData.PRIVATE_KEY_1);
320320

321321
this.content = '';
322-
// Read test.zi from ‘resources’ folder.
322+
// Read irc2-token.jar from ‘resources’ folder.
323323
```
324324

325325
Enter the basic information of the token you want to deploy.
@@ -338,7 +338,7 @@ You can get the maximum step limit value as follows.
338338
// GOVERNANCE_ADDRESS : cx0000000000000000000000000000000000000001
339339
async getMaxStepLimit() {
340340
const { CallBuilder } = IconBuilder;
341-
341+
342342
const governanceApi = await this.iconService.getScoreApi(MockData.GOVERNANCE_ADDRESS).execute();
343343
// "getMaxStepLimit" : the maximum step limit value that any SCORE execution should be bounded by.
344344
const methodName = 'getMaxStepLimit';
@@ -370,15 +370,15 @@ async buildDeployTransaction() {
370370
const decimals = IconConverter.toBigNumber("18");
371371
const tokenName = "StandardToken";
372372
const tokenSymbol = "ST";
373-
const contentType = "application/zip";
373+
const contentType = "application/java";
374374
// Enter token information
375-
// key name ("initialSupply", "decimals", "name", "symbol")
375+
// key name ("_initialSupply", "_decimals", "_name", "_symbol")
376376
// You must enter the given values. Otherwise, your transaction will be rejected.
377377
const params = {
378-
initialSupply: IconConverter.toHex(initialSupply),
379-
decimals: IconConverter.toHex(decimals),
380-
name: tokenName,
381-
symbol: tokenSymbol
378+
_initialSupply: IconConverter.toHex(initialSupply),
379+
_decimals: IconConverter.toHex(decimals),
380+
_name: tokenName,
381+
_symbol: tokenSymbol
382382
}
383383
const installScore = MockData.SCORE_INSTALL_ADDRESS;
384384
const stepLimit = await this.getMaxStepLimit();
@@ -402,8 +402,8 @@ async buildDeployTransaction() {
402402
.content(`0x${this.content}`)
403403
.params(params)
404404
.version(version)
405-
.build();
406-
return transaction;
405+
.build();
406+
return transaction;
407407
}
408408
```
409409

@@ -463,7 +463,7 @@ You can get a step cost to send token as follows.
463463
```javascript
464464
async getDefaultStepCost() {
465465
const { CallBuilder } = IconBuilder;
466-
466+
467467
// Get apis that provides Governance SCORE
468468
// GOVERNANCE_ADDRESS : cx0000000000000000000000000000000000000001
469469
const governanceApi = await this.iconService.getScoreApi(MockData.GOVERNANCE_ADDRESS).execute();
@@ -506,7 +506,7 @@ async buildTokenTransaction() {
506506
_to: MockData.WALLET_ADDRESS_2,
507507
_value: IconConverter.toHex(value)
508508
}
509-
509+
510510
//Enter transaction information
511511
const tokenTransactionBuilder = new CallTransactionBuilder();
512512
const transaction = tokenTransactionBuilder
@@ -518,7 +518,7 @@ async buildTokenTransaction() {
518518
.method(methodName)
519519
.params(params)
520520
.version(version)
521-
.build();
521+
.build();
522522
return transaction;
523523
}
524524
```
@@ -652,13 +652,13 @@ async syncBlock(block) {
652652

653653
const tokenName = await this.getTokenName(transaction.to);
654654
const symbol = await this.getTokenSymbol(transaction.to);
655-
655+
656656
document.getElementById("S03-2").innerHTML += `<li>${block.height} - [${tokenName} - ${symbol}] status: ${txResult.status === 1 ? 'success' : 'failure'} | amount: ${value}</li>`;
657657
}
658658
}
659659
})
660660
)
661-
661+
662662
this.prevHeight = block.height;
663663
}
664664

@@ -697,5 +697,5 @@ async getTokenSymbol(to) {
697697

698698
## References
699699

700-
- [ICON JSON-RPC API v3](https://icondev.readme.io/docs/json-rpc-specification)
700+
- [ICON JSON-RPC API v3](https://icondev.readme.io/docs/json-rpc-specification)
701701
- [IRC2 Specification](https://github.com/icon-project/IIPs/blob/master/IIPS/iip-2.md)
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,72 @@
11
<html>
2-
<head>
3-
<title>DeployAndTransferTokenExample - ICON SDK JS QUICKSTART</title>
4-
<style>
5-
body {
6-
padding-left: 30px;
7-
}
8-
</style>
9-
</head>
10-
<body>
11-
<br />
12-
<h2>DeployAndTransferTokenExample</h2>
13-
<p>An example of deploying IRC token and transferring deployed token.</p>
14-
<br />
15-
<hr>
16-
<br />
17-
<div>
18-
<h3>1. Upload Score File</h3>
19-
<p>Read the binary data from ‘./resource/test.zi’</p>
20-
<form action='#' onsubmit="return false;">
21-
<input type='file' id='fileinput' />
22-
<input type='button' id='D01' value='Deploy ST Token' />
23-
</form>
24-
<p><span id='D01-1'></span></p>
25-
<p><span id='D01-2'></span></p>
26-
<p><span id='D01-3'></span></p>
27-
</div>
28-
<br />
29-
<hr>
30-
<br />
31-
<div>
32-
<h3>2. Check Score Deployment TX Status</h3>
33-
<button id='D02'>Check Score Deployment TX Status</button>
34-
<p><span id='D02-1'></span></p>
35-
<p><span id='D02-2'></span></p>
36-
<p><span id='D02-3'></span></p>
37-
</div>
38-
<br />
39-
<hr>
40-
<br />
41-
<div>
42-
<h3>3. Send ST Token</h3>
43-
<p>Transfer 1 ST Token to hxd008c05cbc0e689f04a5bb729a66b42377a9a497</p>
44-
<button id='D03'>Send ST Token</button>
45-
<p><span id='D03-1'></span></p>
46-
<p><span id='D03-2'></span></p>
47-
</div>
48-
<br />
49-
<hr>
50-
<br />
51-
<div>
52-
<h3>4. Check ST Token Balance</h3>
53-
<span id='D04-1'></span>
54-
<p>hx902ecb51c109183ace539f247b4ea1347fbf23b5: <span id='D04-2'>0</span> ST</p>
55-
<p>hxd008c05cbc0e689f04a5bb729a66b42377a9a497: <span id='D04-3'>0</span> ST</p>
56-
<button id='D04'>Reload Token Balance</button>
57-
</div>
58-
<br />
59-
<hr>
60-
<br />
61-
<div>
62-
<h3>5. Check ST Token Transaction TX Status</h3>
63-
<p><span id='D05-1'></span></p>
64-
<p><span id='D05-2'></span></p>
65-
<button id='D05'>Check TX Status</button>
66-
</div>
67-
</body>
68-
</html>
2+
<head>
3+
<title>DeployAndTransferTokenExample - ICON SDK JS QUICKSTART</title>
4+
<style>
5+
body {
6+
padding-left: 30px;
7+
}
8+
</style>
9+
</head>
10+
<body>
11+
<br />
12+
<h2>DeployAndTransferTokenExample</h2>
13+
<p>An example of deploying IRC token and transferring deployed token.</p>
14+
<br />
15+
<hr />
16+
<br />
17+
<div>
18+
<h3>1. Upload Score File</h3>
19+
<p>Read the binary data from ‘./resource/irc2-token.jar’</p>
20+
<form action="#" onsubmit="return false;">
21+
<input type="file" id="fileinput" />
22+
<input type="button" id="D01" value="Deploy ST Token" />
23+
</form>
24+
<p><span id="D01-1"></span></p>
25+
<p><span id="D01-2"></span></p>
26+
<p><span id="D01-3"></span></p>
27+
</div>
28+
<br />
29+
<hr />
30+
<br />
31+
<div>
32+
<h3>2. Check Score Deployment TX Status</h3>
33+
<button id="D02">Check Score Deployment TX Status</button>
34+
<p><span id="D02-1"></span></p>
35+
<p><span id="D02-2"></span></p>
36+
<p><span id="D02-3"></span></p>
37+
</div>
38+
<br />
39+
<hr />
40+
<br />
41+
<div>
42+
<h3>3. Send ST Token</h3>
43+
<p>Transfer 1 ST Token to hxd008c05cbc0e689f04a5bb729a66b42377a9a497</p>
44+
<button id="D03">Send ST Token</button>
45+
<p><span id="D03-1"></span></p>
46+
<p><span id="D03-2"></span></p>
47+
</div>
48+
<br />
49+
<hr />
50+
<br />
51+
<div>
52+
<h3>4. Check ST Token Balance</h3>
53+
<span id="D04-1"></span>
54+
<p>
55+
hx902ecb51c109183ace539f247b4ea1347fbf23b5: <span id="D04-2">0</span> ST
56+
</p>
57+
<p>
58+
hxd008c05cbc0e689f04a5bb729a66b42377a9a497: <span id="D04-3">0</span> ST
59+
</p>
60+
<button id="D04">Reload Token Balance</button>
61+
</div>
62+
<br />
63+
<hr />
64+
<br />
65+
<div>
66+
<h3>5. Check ST Token Transaction TX Status</h3>
67+
<p><span id="D05-1"></span></p>
68+
<p><span id="D05-2"></span></p>
69+
<button id="D05">Check TX Status</button>
70+
</div>
71+
</body>
72+
</html>

quickstart/resource/irc2-token.jar

3.23 KB
Binary file not shown.

quickstart/resource/test.zi

-4.71 KB
Binary file not shown.

0 commit comments

Comments
 (0)