Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multitoken ZRC #71

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
ab10242
created some files
vporton Oct 27, 2020
9cab80e
created initial (non-functional but compilable) ZRC5 contract
vporton Oct 27, 2020
3eafa8f
made compilable
vporton Oct 27, 2020
e2dfd67
creating mirrored tokens
vporton Oct 27, 2020
594dfa8
made working contract
vporton Oct 27, 2020
5638932
contract updated
vporton Oct 27, 2020
9df31e3
created a test file (yet wrong)
vporton Oct 27, 2020
c06cc67
contract bug fix
vporton Oct 27, 2020
978eedf
a test almost finished
vporton Oct 27, 2020
6ef537a
bug fixes
vporton Oct 28, 2020
2fb4643
it works
vporton Oct 28, 2020
9fee92e
renamed wrongly named folder
vporton Oct 28, 2020
bab5930
example/zrc6/ZRC-6.md
vporton Oct 28, 2020
2b0d230
zrc-6.md created
vporton Oct 30, 2020
3546d1c
added name, symbol, decimals, init_supply
vporton Oct 30, 2020
6581e9d
preliminary version of ZRC-6
vporton Oct 30, 2020
d411120
bug fix
vporton Oct 30, 2020
bb9e2ef
new error
vporton Oct 30, 2020
b62eee9
bug fix
vporton Oct 30, 2020
09b52d9
bug fix
vporton Oct 30, 2020
2040807
an additional event
vporton Oct 30, 2020
8f66969
bug fix
vporton Oct 30, 2020
41040ca
remark
vporton Oct 30, 2020
27c2193
bug fix
vporton Oct 30, 2020
8c8e42a
grammar
vporton Oct 30, 2020
a4e0b9f
bug fix
vporton Oct 30, 2020
7b889f9
bug fix
vporton Oct 30, 2020
87558e8
bug fix
vporton Oct 30, 2020
eb44131
formatting
vporton Oct 30, 2020
211e519
bug fix
vporton Oct 30, 2020
2e984cc
bug fixes
vporton Oct 30, 2020
2d51484
standard number correction
vporton Oct 30, 2020
e53c062
multi-token operations
vporton Oct 30, 2020
a78681d
bug fix
vporton Oct 30, 2020
3bd8a81
bug fixes
vporton Oct 30, 2020
e1ecab0
bug fix
vporton Oct 30, 2020
ae7652c
bug fix
vporton Oct 30, 2020
09ce4b7
bug fix
vporton Oct 30, 2020
aedce85
bug fix
vporton Oct 30, 2020
fdeaa24
title fix
vporton Oct 30, 2020
d90a306
ZRC
vporton Oct 30, 2020
bd2a32c
BalancesMultiple
vporton Oct 30, 2020
6bdd50b
typo
vporton Oct 30, 2020
c21e83f
formatting
vporton Oct 30, 2020
046ffcd
typo
vporton Oct 30, 2020
8e121da
typo
vporton Oct 30, 2020
5ecdc3d
typos
vporton Oct 30, 2020
94fe9a2
typo
vporton Oct 30, 2020
47d1148
typos
vporton Oct 30, 2020
09ca052
contract address updated
vporton Oct 30, 2020
1eb010b
test bug fix
vporton Oct 30, 2020
3b41ea5
test bug fix
vporton Oct 30, 2020
80030b1
tested
vporton Oct 30, 2020
fc20323
TODO
vporton Oct 30, 2020
ce5507b
Multiple in events
vporton Oct 30, 2020
b409f29
added error
vporton Oct 30, 2020
75dc7b7
grammar
vporton Oct 30, 2020
255a01c
about token URIs
vporton Oct 30, 2020
e9da912
removed a TODO
vporton Oct 30, 2020
acf32ef
typo
vporton Oct 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions example/zrc6/ZRC-6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ZRC-6 token example

WARNING: The ZRC-6 standard is not yet finalished and even not yet
published.

The example ZRC-6 token `FungibleMultiToken` accepts deposits of any
(registered with `CreateZRC2BridgeToken` transition) ZRC-2 token and
converts it 1-1 to a ZRC-6 token. The ZRC-6 tokens are held by
`FungibleMultiToken` contract and can be withdrawn back.

This is useful for future applications when ZRC-2 will probably become
a so much outdated legacy that there will be no support for it, but we
would use ZRC-6 instead.

For example, it allows to make a new version of $XSGD that will be ZRC-6
based and easy convertible 1-1 forth and back from old ZRC-2 $XSGD.

I will probably keep working on my ZRC-6 as a response to
https://gitcoin.co/issue/Zilliqa/zilliqa-bounties/1/100023732
75 changes: 75 additions & 0 deletions example/zrc6/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const fs = require('fs');
const {Long, bytes, units} = require('@zilliqa-js/util');
const {Zilliqa} = require('@zilliqa-js/zilliqa');
const {getAddressFromPrivateKey} = require('@zilliqa-js/crypto');

const zilliqa = new Zilliqa('https://dev-api.zilliqa.com');


async function main() {
const CHAIN_ID = 333;
const MSG_VERSION = 1;
const VERSION = bytes.pack(CHAIN_ID, MSG_VERSION);
privkey = '07e0b1d1870a0ba1b60311323cb9c198d6f6193b2219381c189afab3f5ac41a9';
zilliqa.wallet.addByPrivateKey(
privkey
);
const address = getAddressFromPrivateKey(privkey);
console.log("Your account address is:");
console.log(`${address}`);
const myGasPrice = units.toQa('2000', units.Units.Li); // Gas Price that will be used by all transactions

console.log("start to deploy zrc2: ");
const code = fs.readFileSync("../../reference/FungibleMultiToken.scilla").toString();
console.log("contract code is: ");
console.log(code);
const init = [
// this parameter is mandatory for all init arrays
{
vname: "_scilla_version",
type: "Uint32",
value: "0"
},
{
vname: "contract_owner",
type: "ByStr20",
value: `${address}`
}
];
console.log("init json is: ");
console.log(JSON.stringify(init));
const contract = zilliqa.contracts.new(code, init);
try {
const [deployTx, ftoken] = await contract.deployWithoutConfirm({
version: VERSION,
gasPrice: myGasPrice,
gasLimit: Long.fromNumber(40000)
}, false);

if (ftoken.error) {
console.error(ftoken.error);
return;
}
// check the pending status
const pendingStatus = await zilliqa.blockchain.getPendingTxn(deployTx.id);
console.log(`Pending status is: `);
console.log(pendingStatus.result);

// process confirm
console.log(`The transaction id is:`, deployTx.id);
console.log(`Waiting transaction be confirmed`);
const confirmedTxn = await deployTx.confirm(deployTx.id);

// Introspect the state of the underlying transaction
console.log(`Deployment Transaction ID: ${deployTx.id}`);

// Get the deployed contract address
console.log("The contract address is:");
console.log(ftoken.address);
} catch (e) {
console.error(e);
}

}

main();
Loading