Skip to content

Create and send your token.cn

Devin edited this page Jan 4, 2019 · 1 revision

自定义通证合约地址:

PCGTta3M4t3yXu8uRgkKvaWd2d8DREThG43

1.准备

对某个地址进行解锁:

personal.unlockAccount("P1FhYmcn3fgMuqLb8S2z4kavnAJcJXVstic","1",600000000) 地址,密码,解锁时间

2.创币调用

from地址,to地址,PTN数量(Dao),手续费(Dao),合约ID(固定的PCGTta3M4t3yXu8uRgkKvaWd2d8DREThG43),方法名(createToken),token名字,token符号(全局唯一),小数最小精度(最大18),token初始总量,增发地址

ptn.ccinvoketx("P1FhYmcn3fgMuqLb8S2z4kavnAJcJXVstic","P1FhYmcn3fgMuqLb8S2z4kavnAJcJXVstic","1000","1","PCGTta3M4t3yXu8uRgkKvaWd2d8DREThG43",["createToken", "zxl test description","zxl","1","1000","P1FhYmcn3fgMuqLb8S2z4kavnAJcJXVstic"])

3.增发调用

from地址,to地址,PTN数量(Dao),手续费(Dao),合约ID(固定的PCGTta3M4t3yXu8uRgkKvaWd2d8DREThG43),方法名(supplyToken),token符号(全局唯一),增发数量

ptn.ccinvoketx("P1FhYmcn3fgMuqLb8S2z4kavnAJcJXVstic","P1FhYmcn3fgMuqLb8S2z4kavnAJcJXVstic","100","1","PCGTta3M4t3yXu8uRgkKvaWd2d8DREThG43",["supplyToken", "zxl","1000"])

4.Token转账

Token资产ID(用getBalance可以看到),from地址,to地址,Token数量,手续费(PTN)

ptn.transferToken("ZXL+I0U1RRBWTSW9LIXC58D","P1FhYmcn3fgMuqLb8S2z4kavnAJcJXVstic","P1CbmPRvSeWXDgN8wZECWUVujirEaxynB8K","1","1")

5.查询Token信息

合约ID(固定的PCGTta3M4t3yXu8uRgkKvaWd2d8DREThG43),方法名(getTokenInfo),token符号(全局唯一)

ptn.ccquery("PCGTta3M4t3yXu8uRgkKvaWd2d8DREThG43", ["getTokenInfo", "zxl"])

查询Token信息:合约ID(固定的PCGTta3M4t3yXu8uRgkKvaWd2d8DREThG43),方法名(getAllTokenInfo)

ptn.ccquery("PCGTta3M4t3yXu8uRgkKvaWd2d8DREThG43", ["getAllTokenInfo"])

6.查看结果用到的方法

ptn.getBalance("P1FhYmcn3fgMuqLb8S2z4kavnAJcJXVstic")

{ PTN: "999999999.99999999", ZXL+P1K1yY3AeXEpK4TfZPnnZvavZ5t5KbY57Zh: "100" }

ptn.ccinvoketx("P1K1yY3AeXEpK4TfZPnnZvavZ5t5KbY57Zh","P1K1yY3AeXEpK4TfZPnnZvavZ5t5KbY57Zh","100","1","PCGTta3M4t3yXu8uRgkKvaWd2d8DREThG43",["supplyToken", "zxl","1000"]) "129e4524dcaf18127d0961387b0e025ae6eadf903fdced90a5aad075ba50d809"

ptn.getTxHashByReqId("0x129e4524dcaf18127d0961387b0e025ae6eadf903fdced90a5aad075ba50d809") "{"item":"tx_hash","info":"0x808616513f44c7b8d1ccec14006f2cdd6dcced924b399c404b6cd581234056e6"}"

ptn.getTxByHash("0x808616513f44c7b8d1ccec14006f2cdd6dcced924b399c404b6cd581234056e6") "{"item":"transaction_info","info":{"txhash":"0x9a3cc0a963bc087112f627009e3b7d6e893eac4835e3c30b252748a5bc827018","unithash":"0x94fec0fa36869de2bba381ddc52d6187b1b3086bd22008d715a3ccca8381dd99","payment":{"inputs":[{"txid":"0x8b2bf90137969287d02186b3c38f475a3e3ec7833590d549645f20cb741b8b98","message_index":0,"out_index":0,"unlock_script":"302a776822f04ecbfa4b507da7bb0344fd3710963760ebe8c88b50c4e5cbe1605aa5b5cefef83e49a152a5c0a5d026f3b3cda566bdf3037ee215406a6061c804 02f50cb748d9e0f8b079a0c8797c6e87850e593d5c919c534e9a63d8bbd62f3167"}],"outputs":[{"amount":100000000000000000,"asset":"PTN","to_address":"P1K1yY3AeXEpK4TfZPnnZvavZ5t5KbY57Zh","lock_script":"OP_DUP OP_HASH160 c5a1750eaca1e05064d27b19c7d044b7f66bb070 OP_EQUALVERIFY OP_CHECKSIG"}],"locktime":0},"txmessages":"[{\"app\":0,\"payload\":{\"inputs\":[{\"pre_outpoint\":{\"txhash\":\"0x8b2bf90137969287d02186b3c38f475a3e3ec7833590d549645f20cb741b8b98\",\"message_index\":0,\"out_index\":0},\"signature_script\":\"QDAqd2gi8E7L+ktQfae7A0T9NxCWN2Dr6MiLUMTly+FgWqW1zv74PkmhUqXApdAm87PNpWa98wN+4hVAamBhyAQhAvUMt0jZ4PiweaDIeXxuh4UOWT1ckZxTTppj2LvWLzFn\",\"extra\":null}],\"outputs\":[{\"value\":100000000000000000,\"pk_script\":\"dqkUxaF1Dqyh4FBk0nsZx9BEt/ZrsHCIrA==\",\"asset\":{\"asset_id\":[64,0,130,187,8,0,0,0,0,0,0,0,0,0,0,0],\"unique_id\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}],\"lock_time\":0}},{\"app\":102,\"payload\":{\"contract_id\":\"AAAAAAAAAAAAAAAAAAAAAAAAAAI=\",\"function_name\":\"\",\"args\":[\"c3VwcGx5VG9rZW4=\",\"enhs\",\"MTAwMA==\"],\"timeout\":0}},{\"app\":3,\"payload\":{\"contract_id\":\"AAAAAAAAAAAAAAAAAAAAAAAAAAI=\",\"function_name\":\"{\\\"invoke_address\\\":\\\"P1K1yY3AeXEpK4TfZPnnZvavZ5t5KbY57Zh\\\",\\\"invoke_tokens\\\":{\\\"amount\\\":0,\\\"asset\\\":{\\\"asset_id\\\":[64,0,130,187,8,0,0,0,0,0,0,0,0,0,0,0],\\\"unique_id\\\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},\\\"invoke_fees\\\":{\\\"amount\\\":1,\\\"asset\\\":{\\\"asset_id\\\":[64,0,130,187,8,0,0,0,0,0,0,0,0,0,0,0],\\\"unique_id\\\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}}\",\"args\":[\"eyJpbnZva2VfYWRkcmVzcyI6IlAxSzF5WTNBZVhFcEs0VGZaUG5uWnZhdlo1dDVLYlk1N1poIiwiaW52b2tlX3Rva2VucyI6eyJhbW91bnQiOjAsImFzc2V0Ijp7ImFzc2V0X2lkIjpbNjQsMCwxMzAsMTg3LDgsMCwwLDAsMCwwLDAsMCwwLDAsMCwwXSwidW5pcXVlX2lkIjpbMCwwLDAsMCwwLDAsMCwwLDAsMCwwLDAsMCwwLDAsMF19fSwiaW52b2tlX2ZlZXMiOnsiYW1vdW50IjoxLCJhc3NldCI6eyJhc3NldF9pZCI6WzY0LDAsMTMwLDE4Nyw4LDAsMCwwLDAsMCwwLDAsMCwwLDAsMF0sInVuaXF1ZV9pZCI6WzAsMCwwLDAsMCwwLDAsMCwwLDAsMCwwLDAsMCwwLDBdfX19\",\"c3VwcGx5VG9rZW4=\",\"enhs\",\"MTAwMA==\"],\"execution_time\":5979600,\"read_set\":[{\"Key\":\"symbols\",\"Version\":{\"height\":{\"asset_id\":[0,64,0,130,187,8,0,0,0,0,0,0,0,0,0,0],\"is_main\":true,\"index\":7},\"tx_index\":1},\"Value\":null}],\"write_set\":[],\"payload\":null}},{\"app\":0,\"payload\":{\"inputs\":null,\"outputs\":[{\"value\":1000,\"pk_script\":\"dqkUxaF1Dqyh4FBk0nsZx9BEt/ZrsHCIrA==\",\"asset\":{\"asset_id\":[64,0,181,233,1,118,57,197,43,77,180,74,17,50,25,223],\"unique_id\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}],\"lock_time\":0}},{\"app\":5,\"payload\":{\"signature_set\":[{\"PubKey\":\"AwAam3i1TE2cr9AOD7ouELFX4foHjCBKU8nELS3C979p\",\"Signature\":\"BJyFzK8lQCPb6MP1NjEflcJB0qkaOlKIlolnnqa8zyFec427pRuQX8zFgjV7Nv1JWcK0luzBgypX0nxA3n6TZwA=\"}]}}]"}}"

Clone this wiki locally