Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:07
    codecov-io commented #539
  • 16:04
    codecov-io commented #539
  • 15:47
    codecov-io commented #539
  • 15:47
    xpepermint synchronize #539
  • 15:47

    xpepermint on 2.0

    Optimize fetch method Dist rebuild Merge pull request #557 from xp… (compare)

  • 15:47
    xpepermint closed #557
  • 15:47
    xpepermint edited #557
  • 15:46
    xpepermint opened #557
  • Sep 19 08:47
    codecov-io commented #539
  • Sep 19 08:30
    codecov-io commented #539
  • Sep 19 08:30
    xpepermint synchronize #539
  • Sep 19 08:30

    xpepermint on 2.0

    Change ability we are setting a… Change order of assigning abili… Move assigning abilities to con… and 1 more (compare)

  • Sep 19 08:30
    xpepermint closed #555
  • Sep 19 08:29
    codecov-io commented #539
  • Sep 19 08:29
    xpepermint synchronize #539
  • Sep 19 08:29

    xpepermint on 2.0

    Add manage abilities proxy. Remove unnecessary variable. Extend abilitable with addition… and 26 more (compare)

  • Sep 19 08:29
    xpepermint closed #556
  • Sep 19 08:25
    codecov-io commented #556
  • Sep 19 08:08
    codecov-io commented #556
  • Sep 19 08:08
    MoMannn synchronize #556
Azlan
@azizazlan

In the https://docs.0xcert.org/api/ethereum.html#bitski-back-end-provider, the descriptions stated that options.requiredConfirmations is an integer representing the number of confirmations needed for mutations to be considered confirmed. It defaults to 1.

So if I have 10 assets to mutate/deploy, then I set the requiredConfirmations to 10. OK fine. However, I am just wondering what the maximum value I can set it to be? 100? 1000?

The motivation is that I want to create a back-end app that capable to transfers assets in bulk, say in a batch of 100 transfers at a time to 100 recipients.

Tadej Vengust
@MoMannn
@azizazlan requiredConfirmations means that when you create a mutation (create a new asset) how many block confimation that transaction has to have for the mutation to consider it complete
so lets say you have requiredConfirmations set to 10:
if you create a mutation like so:
const mutation = await assetLedger.createAsset({...});
await mutation.complete() // this will wait until the tx is accepted into the blockchain and 10 blocks have passed (with ethereum having 15 seconds block that means a minimum of 150seconds).
meaning this has nothing to do with the amount of transfers you want to do but only with the amount of blocks you are willing to wait for to say it is complete (more confirmations the higher the security and certainty)
Tadej Vengust
@MoMannn
if you want to create/transfer multiple assets in a single mutation I suggest using orderGateway.
Azlan
@azizazlan
Yes you told me already. Sorry for asking the same thing! Thanks anyway @MoMannn !
Tadej Vengust
@MoMannn
@azizazlan No problem :) That is why we are here.
Azlan
@azizazlan

Say the following is the order, consisting an array of actions of CREATE_ASSET for a list of recipients:

const order = {
    makerId: myAccount,
    takerId: myAccount, // maker and taker is the same person?
    actions: [
        {
            kind: OrderActionKind.CREATE_ASSET,
            ledgerId: assetLedgerId,
            receiverId: recipientAccounts[index],
            assetId: recipientAssetIds[index],
            assetImprint: recipientAssetImprints[index]
        },       
        {...},
        {...},
    ],
    seed: Date.now(), // unique order identification
    expiration: Date.now() + 60 * 60 * 24, // 1 day
} as Order;

Can I claim the order if the Maker and Taker is actually the same person (say, myAccount)? Then can I do the followings?

const signedClaim = await orderGateway.claim(order);
const mutation = await orderGateway.perform(order, signedClaim);

If so, is this a correct approach? FYI, in my use case, there is only me and recipients who will receive my ERC721 tokens.

Azlan
@azizazlan

Anyway I got the ProviderError. FYI, I already have 3ETH from the faucet and rinkeby's orderGatewayId from https://docs.0xcert.org/api/ethereum.html#public-addresses. I also have setup my Backend Credential - client id and it's secret.

Perhaps this is because makerId's publicKey is the same as takerId's?

{ ProviderError: GenericProvider error [issue: 0]
    at Object.parseError (/Users/azlanaziz/thuleen-apps/thuminter/node_modules/@0xcert/ethereum-generic-provider/dist/core/errors.js:9:16)
    at Promise.catch (/Users/azlanaziz/thuleen-apps/thuminter/node_modules/@0xcert/ethereum-generic-provider/dist/core/provider.js:164:32)
  name: 'ProviderError',
  issue: 0,
  original:
   { Error: gas required exceeds allowance (7006682) or always failing transaction
     message:
      'gas required exceeds allowance (7006682) or always failing transaction',
     code: -32603 }
Azlan
@azizazlan

My assetLedger is on the Rinkeby network and I instantiates the BitskiProvider like the following. I also set the sandbox option to true.

    var bitskiBackEndProvider = new BitskiProvider({
        sandbox: true, //<<-- I set the sandbox to true
        orderGatewayId: orderGatewayId, //<<-- BUT THIS IS FOR ROPSTEN refers to the doc!
        clientId: myClientId,
        networkName: "rinkeby", // <<---RINKEBY
        credentialsId: myCredentialsId,
        credentialsSecret: myCredentialsSecret,
        accountId: "0x893d78de438b6bf445ebead847a772d98732bf82",
    });

Anyhow the ProviderError (previously encountered) goes away if I choose any of the Ropsten contract addresses from here https://docs.0xcert.org/api/ethereum.html#public-addresses. In other words setting orderGatewayId to any of the Ropsten smart contracts seems to work, Instead of Rinkeby's which is what I wanted!

I said it goes away because it returns a mutation object and console.log it, like the following:

    const orderGateway = OrderGateway.getInstance(bitskiBackEndProvider, orderGatewayId);
    const signedClaim = await orderGateway.claim(order);

    try {
        const mutation = await orderGateway.perform(order, signedClaim);
        console.log(mutation);
    } catch (err) {
        process.exit(0);
    }
Quyen Nguyen
@qnguyen12
hi there, wondering how could I get Transaction Fee of mutations? I think currently you don't have? e.g. createAsset()
Tadej Vengust
@MoMannn
@azizazlan Yes you can be the maker and the taker of an order.
gas required exceeds allowance (7006682) or always failing transaction
Means that on the ethereum smart contract level it failed. Usually because of wrokng permissions etc.
bitski only supports rinkeby and mainnet networks
hm, that is weird. Can you try with sendbox false and send me the mutation.id ? (that is the transaction hash that you can check on etherscan)
Tadej Vengust
@MoMannn
@qnguyen12 Since transaction fee is super dynamic can depend on current network state we have a different mechanism for calculating the transaction fee. Mainly it goes like this: first we estimate the gas needed for the transaction then we get the current gas price of the network and then we multiply the price with the gasPriceMultiplier paramether you can set in provider. That way we can adjust the transaction fee dynamically based on the network.
But if you want the current estimate gas you just set the sandbox option on provider to true and you will get the gas estimation as a result and the mutation will not get broadcasted to the network
Azlan
@azizazlan
Set sandbox to false and the following is how I set the options:
    var bitskiBackEndProvider = new BitskiProvider({
        sandbox: false,
        clientId: myClientId,
        networkName: "rinkeby", // <<---RINKEBY
        credentialsId: myCredentialsId,
        credentialsSecret: myCredentialsSecret,
        accountId: "0x893d78de438b6bf445ebead847a772d98732bf82",
    });

    const order = {
            makerId: makerId,
            takerId: takerId,
            actions: [
                {
                   kind: OrderActionKind.CREATE_ASSET,
                   ledgerId: assetLedgerId,
                   senderId: makerId,
                   receiverId: receiver.publicKey,
                   assetId: receiver.tokenId,
                   assetImprint: receiver.assetImprint
               }
            ],
            seed: Date.now(), // unique order identification
            expiration: Date.now() + 60 * 60 * 24, // 1 day
    };

   // According to the https://docs.0xcert.org/api/ethereum.html#public-addresses below is Ropsten
   const orderGatewayId = "0x0e4f45ad9bca9f214e73683f734f5b1aa3a4051a";
   const orderGateway = OrderGateway.getInstance(bitskiBackEndProvider, orderGatewayId);
   const signedClaim = await orderGateway.claim(order);

    try {
            const mutation = await orderGateway.perform(order, signedClaim).then((mutation) => {
                return mutation.complete();
            });
            console.log(`  Transaction id: ${mutation.id}`);
     } catch (err) {
            process.exit(0);
     }
Azlan
@azizazlan
Transaction (mutation) Id:
0x274272a10a06367d73866d8f2e71e5adc091aac454e61a171ef2d548190e9ea8
https://rinkeby.etherscan.io/tx/0x274272a10a06367d73866d8f2e71e5adc091aac454e61a171ef2d548190e9ea8
Azlan
@azizazlan

I also checked the balance for the receiver - who should receive the newly created asset in the order - but I get zero balance.

var bitskiBackEndProvider = new BitskiProvider({
    orderGatewayId: "0x0e4f45ad9bca9f214e73683f734f5b1aa3a4051a", //Ropsten or rinkeby?
    clientId: myClientId,
    networkName: "rinkeby",
    credentialsId: myCredentialsId,
    credentialsSecret: myCredentialsSecret,
    accountId: "0x893d78de438b6bf445ebead847a772d98732bf82",
});
// Using asset ledger id which I already deployed earlier
const assetLedger = await AssetLedger.getInstance(bitskiBackEndProvider, assetLedgerId);
try {
    balance = await assetLedger.getBalance(receiverAccountId);
    console.log(balance);
} catch (err) {
    process.exit(0);
}

but my makerId Ether balance was deducted.

Tadej Vengust
@MoMannn
You need to change the ropsten address to rinkeby address for orderGatewayId
the same address exists on rinkeby but it is a non smart contract normal address, that is why it does not fail
orderGatewayId needs to be the rinkeby address one
the reason that one fails is probably something with permissions. Did you grant all the necessary abilities?
Check the code here: https://stackblitz.com/edit/atomic-order-example It shows how you need to assign mint ability first
Because orderGateway needs to have permission to create a new asset in your name
Azlan
@azizazlan
I did not grant the mint ability. I try again. Thanks @MoMannn.
Tadej Vengust
@MoMannn
No problem
Azlan
@azizazlan

The following is my code:

const bitskiBackEndProvider = new BitskiProvider({
    orderGatewayId: "0x1707f3e4cbfa103cbf51cbbc129ef70123e41d28", //rinkeby's
    clientId: "b84ef2b8-3ede-4add-85de-6aca9d744a50",
    networkName: "rinkeby",
    credentialsId: myCredentialsId,
    credentialsSecret: myCredentialsSecret,
    accountId: makerId //balance about 3 ETHER
});

const assetLedger = await AssetLedger.getInstance(bitskiBackEndProvider, assetLedgerId);
const assetLedgerInfo = await assetLedger.getInfo();

const orderGateway = OrderGateway.getInstance(bitskiBackEndProvider, orderGatewayId);
const signedClaim = await orderGateway.claim(order);

const mutation = await assetLedger.grantAbilities(orderGateway, [GeneralAssetLedgerAbility.CREATE_ASSET]).then((mutation) => {
    return mutation.complete();
}).catch((err) => {        
    console.log(err);
});

I still got the following error even to grant the ability - not performing any order yet.

{ ProviderError: GenericProvider error [issue: 0]
    at Object.parseError (/Users/azlanaziz/thuleen-apps/thuminter/node_modules/@0xcert/ethereum-generic-provider/dist/core/errors.js:9:16)
    at Promise.catch (/Users/azlanaziz/thuleen-apps/thuminter/node_modules/@0xcert/ethereum-generic-provider/dist/core/provider.js:164:32)
  name: 'ProviderError',
  issue: 0,
  original:
   { Error: gas required exceeds allowance (7474283) or always failing transaction
     message:
      'gas required exceeds allowance (7474283) or always failing transaction',
     code: -32603 },
  message: 'GenericProvider error [issue: 0]' }
Azlan
@azizazlan
also note that BitskiProvider is the back-end version const { BitskiProvider } = require("@0xcert/ethereum-bitski-backend-provider");
Tadej Vengust
@MoMannn
Is makerId the owner of the asset ledger?
Meaning the one who created it? Because only that account gets the ManageAbility that is able to grant someone else create asset ability
Tadej Vengust
@MoMannn
You can also do: assetLedger. getAbilities(makerId) to find all the abilities that you have
Azlan
@azizazlan
ok i try again thanks @MoMannn
Azlan
@azizazlan

I have my own custom jsonschema -for an academic certificate, but I do not know how to generate the corresponding schemaId which is required in the recipe below?

In other words not schema88 - which its schemaId can be obtained the github https://github.com/0xcert/framework/blob/master/conventions/88-crypto-collectible-schema.md

  const recipe = {
    name: "My Own Certificate",
    symbol: "MOC",
    uriBase: "www.moc.com/tokenMetadata/", 
    schemaId: "0x.." //<<---how to get/generate this?
    capabilities: [
      AssetLedgerCapability.DESTROY_ASSET,
      AssetLedgerCapability.UPDATE_ASSET,
      AssetLedgerCapability.TOGGLE_TRANSFERS,
      AssetLedgerCapability.REVOKE_ASSET
    ]
  };

Or am I missing the whole point! Why not just use the schema88 as an academic certificate is after all a crypto collectible!?

Azlan
@azizazlan
ok no worries I got it!
Tadej Vengust
@MoMannn
:thumbsup:
Azlan
@azizazlan

So this time, I am the Maker (accountId "0x893D78DE438b6BF445EbEAd847a772d98732BF82") of the newly deployed AssetLedger ("0x17e0C20BD537a691D6Dd709b94333470dEbaBe77").

I checked at etherscan https://rinkeby.etherscan.io/address/0x17e0c20bd537a691d6dd709b94333470debabe77
and all fine!

I also checked the Maker have the following abilities using assetLedger. getAbilities(makerId):

'MANAGE_ABILITIES',
'CREATE_ASSET',
'REVOKE_ASSET',
'TOGGLE_TRANSFERS',
'UPDATE_ASSET',
'UPDATE_URI_BASE',
'ALLOW_UPDATE_ASSET_IMPRINT

As suggested, next I wanted to grant the orderGateway the abilities to CREATE_ASSET and TOGGLE_TRANSFERS. So the followings are my code:

const orderGatewayId = "0x1707f3e4cbfa103cbf51cbbc129ef70123e41d28";//rinkeby

var options = {
        sandbox: false,
        clientId: "b84ef2b8-3ede-4add-85de-6aca9d744a50",
        networkName: "rinkeby",
        credentialsId: "...",
        credentialsSecret: "...",
        requiredConfirmations: 10,
        orderGatewayId: orderGatewayId,
        accountId: "0x893D78DE438b6BF445EbEAd847a772d98732BF82"
};
const bitskiBackEndProvider = new BitskiProvider(options);

const orderGateway = await OrderGateway.getInstance(bitskiBackEndProvider,orderGatewayId);
const signedClaim = await orderGateway.claim(order); // for brevity I exclude order declaration here

const abilities = [
        GeneralAssetLedgerAbility.CREATE_ASSET,
        GeneralAssetLedgerAbility.TOGGLE_TRANSFERS,
    ];

const grantAbilitiesMutation = await assetLedger.grantAbilities(orderGateway, abilities).then((mutation) => {
        return mutation.complete();
    }).catch((err) => {
        spinner.fail("Failed to grant abilities!");
        console.log(err)        
        process.exit(0);
    });

Still Generic Provider error but a little "progress" - as now the error says something else!

{ ProviderError: GenericProvider error [issue: 0]
    at Object.parseError (/Users/azlanaziz/thuleen-apps/thuminter/node_modules/@0xcert/ethereum-generic-provider/dist/core/errors.js:9:16)
    at Promise.catch (/Users/azlanaziz/thuleen-apps/thuminter/node_modules/@0xcert/ethereum-generic-provider/dist/core/provider.js:164:32)
  name: 'ProviderError',
  issue: 0,
  original:
   { Error: invalid argument 0: json: cannot unmarshal non-string into Go struct field CallArgs.from of type common.Address
     message:
      'invalid argument 0: json: cannot unmarshal non-string into Go struct field CallArgs.from of type common.Address',
     code: -32603 },
  message: 'GenericProvider error [issue: 0]' }

Search through stackoverflow.com on cannot unmarshal non-string into Go struct but to no avail. As far as my code is concern the only non-string params are in the options to instantiates BitskiProvider.

Tadej Vengust
@MoMannn
This is an error that somewhere parsing to ethereum address is failing
check all of your addresses if somewhere there is a mistake?
or you can try putting al the addresses to lower case first
Azlan
@azizazlan
Thanks @MoMannn. Its the lower case that causes the error.
Tadej Vengust
@MoMannn
Ok, that is something the framework should handle by itself. Will add it to the todo list
Azlan
@azizazlan

In one app using version, 2.0.0-alpha5, when I console.log assetLedgerInfo for line const assetLedgerInfo = await assetLedger.getInfo(), I got:

name: "Certificate name"
schemaId: "0x..."
supply: 1
symbol: "CN"
uriPostfix: null,
uriPrefix: null

but in my another app using version 1.9.0, I got:

name: "Certificate name"
schemaId: "0x..."
supply: 1
symbol: "CN"
uriBase: "www.cn.com/assets/",  // <---uriBase missing!
schemaId: "..."

I need the uriBase value, now it is lost. So should I use the same version for both apps? Or my approach of depending on assetLedgerInfo to get uriBase is wrong?

Tadej Vengust
@MoMannn
@azizazlan you should use the stable 1.9.2 version. The 2.0 version is still in the alpha stage and has some breaking changes from 1.x version (since there will be 0xcert protocol changes in 2.0). One of those is uriBase. Which will be split into uriPrefix and uriPostfix.
Azlan
@azizazlan
Ok thanks @MoMannn !
Quyen Nguyen
@qnguyen12
Hi, I am testing on Kovan network. After creating an asset ledger, the etherscan websites say it found another 15 contracts with exact matching byte codes. I think you can add some things while deploying a new asset ledger so each contract has different byte codes?
https://kovan.etherscan.io/find-similar-contracts?a=0x207859d776f81908dbcf10248485f5f87ff6dec1&lvl=5
Tadej Vengust
@MoMannn
@qnguyen12 Well the contract that gets deployed is the same. That is why you can find others. But I fail to see why that would be a problem.
you can change the source of the contract that gets deployed if you like. on provider you have asestLedgerSource field where you can specify your own source if you want otherwise the source is from: https://docs.0xcert.org/xcert-mock.json