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

[$3000 iDNA] Integrate TimeLock or Multisig smart contracts #627

Open
midenaio opened this issue Feb 4, 2021 · 9 comments
Open

[$3000 iDNA] Integrate TimeLock or Multisig smart contracts #627

midenaio opened this issue Feb 4, 2021 · 9 comments

Comments

@midenaio
Copy link
Member

midenaio commented Feb 4, 2021

[$3000 iDNA] Integrate TimeLock or Multisig smart contracts

Prize pool

Total prize pool is 25K iDNA. There are 5 prizes to be distributed:
12K iDNA - 1 prize
7K iDNA - 1 prize
2K iDNA - 3 prizes

All the prizes are paid in iDNA at the price of $0.12.

Challenge description

Submission Requirements

Timelock wallet (prizes: 2K-7K iDNA)
A website that allows any validated or not validated Idena user to create a TimeLock wallet with a specified unlock time.

Functions:

  • Deploy a time lock wallet
  • Send funds
  • Unlock funds
  • etc.

Multisig wallet (prizes: 2K-12K iDNA)
A website that allows any validated or not validated Idena user to create a wallet controlled by multiple members.

Functions:

  • Deploy a multisig wallet
  • Define a list of participants
  • Initiate a transfer
  • Confirm the transfer
  • Push the confirmed transfer
  • etc.

Other: participants may choose any other use cases for development. The maximum size of the awarded prize will depend on the use case complexity.

All code must be open source. All submissions must be working solutions. Submissions must use Idena smart contracts.

How to participate

Apply and submit results in comments to the issue.

Hackathon dates

February 10 - March 3, 2021

Submission deadline

18:00 UTC, March 3, 2021

Resources

Idena smart contracts
Start reading about smart contracts here:
https://github.com/idena-network/idena-desktop/wiki/Idena-smart-contracts

Predefined smart contracts:
https://github.com/idena-network/idena-desktop/wiki/TimeLock
https://github.com/idena-network/idena-desktop/wiki/Multisig

Raw transactions
Sending raw transactions with the Idena app:
https://github.com/idena-network/idena-desktop/wiki/DNA-url#4-sign-and-send-a-raw-transaction

Protobuf model of transactions
https://github.com/idena-network/idena-go/blob/master/protobuf/models.proto#L6

Raw transaction examples
https://github.com/idena-network/idena-examples/tree/master/nodejs-protobuf-transaction-signing

Sign-in with Idena
https://github.com/idena-network/idena-desktop/wiki/Sign-in-with-Idena

Idena RPC
http://rpc.idena.io

Judging Criteria

How likely the application is to be used
Novelty of the use case
The potential positive impact for the Idena ecosystem

The decision on awarding prizes will be made on the basis of voting by Idena network participants and expert opinion (the Idena team and community developers). The size of the awarded prize will depend on complexity and quality of the submission.

The Idena team may consider funding further development of the winning solutions governed by the oracles voting.

Winner Announcement Date

Shortly after reviewing results by the Idena team and community voting.

@redDwarf03
Copy link

Hello. I try to play with Timelock but I don't understand where are my coins.....

  1. I deployed my contract:
{
  "method": "contract_deploy",
  "params": [
    {
      "from": "0x72563cb949bd0167acfff47b5865fe30e1960e70",
      "codeHash": "0x01",
      "amount": 10,
      "maxFee": 0.25,
      "args": [
        {
          "index": 0,
          "format": "uint64",
          "value": "1613509380"
        }
      ]
    }
  ],
  "id": 34,
  "key": "12345678765432345"
}

I obtained :

{
  "jsonrpc": "2.0",
  "id": 34,
  "result": "0xfdbf62e5432e6205cdd9151653e63d5e491116160aa078ca50929e8026320b4a"
}
  1. I called before the end of time the method transfer
{
  "method": "contract_call",
  "params": [
    {
      "from": "0x72563cb949bd0167acfff47b5865fe30e1960e70",
      "contract": "0x43a62b90eaeba972ff6d86707984787c3e0c42db",
      "method": "transfer",
      "amount": 10,
      "maxFee": 0.25,
      "args": [
        {
          "index": 0,
          "format": "hex",
          "value": "0xf429e36d68be10428d730784391589572ee0f72b"
        },
        {
          "index": 1,
          "format": "dna",
          "value": "10"
        }
      ]
    }
  ],
  "id": 35,
  "key": "1234567876543"
}

I obtained:

{
  "jsonrpc": "2.0",
  "id": 35,
  "result": "0xb5988caa7bdd7067efea32d974e9aaada923dbcb4f007047317163d5edeae729"
}
  1. I launched another time the transfer method and the result was ok

My dest address didn't receive coins...

  1. I tried to call Terminate method
{
  "method": "contract_terminate",
  "params": [
    {
      "from": "0x72563cb949bd0167acfff47b5865fe30e1960e70",
      "contract": "0x43a62b90eaeba972ff6d86707984787c3e0c42db",
      "maxFee": 0.25,
      "args": [
        {
          "index": 0,
          "format": "hex",
          "value": "0xf429e36d68be10428d730784391589572ee0f72b"
        }
      ]
    }
  ],
  "id": 41,
  "key": "12345678765432"
}

I obtained

{
  "jsonrpc": "2.0",
  "id": 41,
  "result": "0xc6c212755ddd84b657e509fbaba446d991dedea5e7deb29fd2678b0ad2cbc648"
}

I didn't receive the 50%

I saw transfers on https://scan.idena.io/contract/0x43a62b90eaeba972ff6d86707984787c3e0c42db
I didn't receive something

Could you help me

Thx

@midenaio
Copy link
Member Author

@redDwarf03

  1. When you deploy the TimeLock contract the specified amount 10 iDNA is locked in the form of the smart contract stake. The balance of the smart contract remains 0 iDNA.

  2. When you call the transfer method it tries to withdraw the coins.

You do not need to specify Amount when unlocking the coins (see example). Otherwise the specified Amount will be transferred to the smart contract address. However, in your case, an error occurred and 10 iDNA was not transferred:

{
  "method": "bcn_txReceipt",
  "params": [
    "0xb5988caa7bdd7067efea32d974e9aaada923dbcb4f007047317163d5edeae729"
  ],
  "id": 20,
  "key": "1a1f81662d9790f480b3c6c15fcde426"
}
{
  "jsonrpc": "2.0",
  "id": 20,
  "result": {
    "contract": "0x43a62b90eaeba972ff6d86707984787c3e0c42db",
    "method": "transfer",
    "success": false,
    "gasUsed": 285,
    "txHash": "0xb5988caa7bdd7067efea32d974e9aaada923dbcb4f007047317163d5edeae729",
    "error": "transfer is locked",
    "gasCost": "0.0005091103965795",
    "txFee": "0.002876027152607"
  }
}

The balance of the smart contract remains 0 iDNA.

You need to use normal send transaction to lock the coins at the TimeLock address.

  1. Another transfer method was called successfully. 10 iDNA was sent to the smart contract and immediately transferred back to your address. The balance of the smart contract remains 0 iDNA.

  2. 50% of the stake was successfully unlocked and 5 iDNA was transferred to your address
    image

@redDwarf03
Copy link

redDwarf03 commented Feb 17, 2021

@midenaio , ok thx. I think I understand. thx you
but one question: why I don't see tx in my address 0xf429e36D68BE10428D730784391589572Ee0f72B ?

@redDwarf03
Copy link

redDwarf03 commented Feb 22, 2021

new questions:

  1. I call contract_estimateDeploy with maxFee = 0 because you say in wiki: « maxFee: not used for contract_estimateDeploy »

But I receive with this request:

{
"method":"contract_estimateDeploy",
"params":[{"from":"0x72563cb949bd0167acfff47b5865fe30e1960e70","codeHash":"0x01","amount":1,"maxFee":0,"args":[{"index":0,"format":"uint64","value":"1613980800000"}]}],
"id":101,
"key":"1234565432"
}
{"jsonrpc":"2.0","id":101,"error":{"code":-32000,"message":"invalid max fee"}}

When I precise 1 in maxFee, the request is good.

  1. in sendTx method, we should use 10^18 to precise amount/maxfee
    In smart contract, the amount is in iDNA.
    I receive error when I precise the amount in double type instead of int
    Normally amount is in String in other method
    I don't know how to send double value

  2. i have a timelock smart contract with address: https://scan.idena.io/contract/0x53c883c366d9973286ac48dda52759b625392d91
    with which method I can get the initial balance and the initial unlock time ?
    I tried with http://api.idena.io/api/TimeLockContract/0x53C883c366d9973286aC48DDa52759b625392D91 but no response

Thank you

@midenaio
Copy link
Member Author

midenaio commented Feb 23, 2021

@redDwarf03

I call contract_estimateDeploy with maxFee = 0 because you say in wiki: « maxFee: not used for contract_estimateDeploy »

You should rather omit the parameter instead of specifying '0' value. Wiki has been updated to make it clear. Thanks for noticing this.

I don't know how to send double value

It's similar to sendTx transaction:

{
  "method": "contract_estimateDeploy",
  "params": [
    {
      "amount": 12.345,
    }
  ]
}

Note: when the specified amount is less than minimum stake the invalid amount error will be returned for the deploy method.

with which method I can get the initial balance

The current contract's balance can be fetched using dna_getBalance node RPC method. You can also read the contract's stake with contract_getStake method.

and the initial unlock time ?

Use contract_readData for getting contract's variables.

Note: The specified timestamp 1614033480000 for the deployed timelock contract is incorrect. I guess it should have been 1614033480 matching February 22, 2021 10:38:00 PM GMT+00:00.

@redDwarf03
Copy link

my contribution with lock time. https://www.youtube.com/watch?v=u_5hOylseiM&feature=youtu.be
back office of all RPC methods is ready too for others smart contracts
source: https://github.com/redDwarf03/my-idena

@redDwarf03
Copy link

redDwarf03 commented Feb 24, 2021

my Idena Mobile App / Hackathon / Time Lock Smart Contract / Demo live all features (6 min)
Version 1 finished for VPS/Local Node.
I'll adapt this feature for shared node next month
https://www.youtube.com/watch?v=8EAn7r06Jyc&feature=youtu.be
source: https://github.com/redDwarf03/my-idena

@redDwarf03
Copy link

after time lock: multisig
my Idena Mobile App / Hackathon / Multisig Smart Contract / Demo live all features (9 min)
The display of contracts doesn't have good performances because it requires to have new methods in the Idena backoffice (RPC or api.Idena.io)
https://www.youtube.com/watch?v=2OZVd61Ofu0&feature=youtu.be
source: https://github.com/redDwarf03/my-idena

@redDwarf03
Copy link

I would like to work for you but I need some answers please ;)) (cf telegram pm)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants