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

xinfin: bounties integration #8421

Merged
merged 4 commits into from
Mar 24, 2021
Merged

Conversation

thelostone-mc
Copy link
Member

@thelostone-mc thelostone-mc commented Feb 22, 2021

Description

This PR integrated the xinfin blockchain onto Gitcoin Bounties.
Funtionallity added:

  • Funder to create a bounty using XDC tokens (permission/permisionless, contest/coop/traditional)
  • Bounty Hunters to apply on bounty -> start work -> submit work
  • Funder to review work and payout the bounty

  • Adds Xinfin in hackathon/bounty form
  • Backend logic to check with blockexplorer API (needs API KEY)
  • Frontend + Backend Wiring

  • Chain ID: 50
  • Token: XDC
  • Decimals: 18
  • Coingecko: xdce-crowd-sale
Testing

https://share.vidyard.com/watch/F2qDBEijVCBVVbAn13PbTy?

@thelostone-mc
Copy link
Member Author

thelostone-mc commented Feb 25, 2021

// SET PROVIDER
const xinfinHost = "https://rpc.xinfin.network";
const xinfinClient = new Web3();
xinfinClient.setProvider(
new xinfinClient.providers.HttpProvider(xinfinHost)
);

================

// GET DEFAULT ADDRESS
console.log(ethereum.selectedAddress) // is null
console.log(xinfinClient.eth.defaultAccount) // is null

================

// GET BALANCE OF ADDRESS

// from xinpay -> if public address is xdc306eb661a29a19d269adcfa73b5afd98b80f47fd
balanceInWei = await xinfinClient.eth.getBalance("xdc306eb661a29a19d269adcfa73b5afd98b80f47fd");
// this fails with msg : Uncaught Error: Provided address "xdc306eb661a29a19d269adcfa73b5afd98b80f47fd" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can't be converted.

balanceInWei = await xinfinClient.eth.getBalance("306eb661a29a19d269adcfa73b5afd98b80f47fd"); // THIS WORKS

================
  
// SEND TRANSACTION

let txArgs = {
      to: "0x306eb661a29a19d269adcfa73b5afd98b80f47fd",
      from: "0xe4114df461966189d2765b8bf0919a96f02ff8ca",
      value: xinfinClient.utils.toWei(String(amount)),
      // gasPrice: xinfinClient.utils.toHex(await xinfinClient.eth.getGasPrice()),
      // gas: xinfinClient.utils.toHex(318730),
      // gasLimit: xinfinClient.utils.toHex(318730)
 };

xinfinClient.eth.sendTransaction(
    txArgs,
    (error, result) => console.log(error, result)
 );

If I attempt to do sendTransaction, I get error unknown account

PS: if I add the prefix XDC on sendTransaction -> it fails with
The Uncaught Error: Provided address "xdc306eb661a29a19d269adcfa73b5afd98b80f47fd" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can't be converted. happens when i attempt to invoke transfer function as well. I assume there is a function I would need to convert the address from xinpay to a suitable format

Untitled

@rudreshsolanki97
Copy link

Hello,

Inorder to interact with XinFin blockchain we'll have to use XinFin's fork of web3 library xdc3 ( Link ).
Being a fork of web3, it has identical interface.

@thelostone-mc thelostone-mc changed the title WIP xinfin: bounties integration Mar 21, 2021
@thelostone-mc thelostone-mc marked this pull request as ready for review March 21, 2021 13:11
Copy link
Contributor

@chibie chibie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice job man! lgtm!

did you also test the backend sync function? it wasn't captured in the vid

@thelostone-mc
Copy link
Member Author

@chibie oh yup ! it did work 🙌
the txn got confirmed pretty quick, so I didn't have to run the sync command

@thelostone-mc thelostone-mc merged commit 3d42b0a into gitcoinco:master Mar 24, 2021
PR Review Board automation moved this from Engineering-Review to Done Mar 24, 2021
iRhonin pushed a commit to iRhonin/web that referenced this pull request Apr 23, 2021
* feat: integrate xinfin/bounties

* add mig file

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

Successfully merging this pull request may close these issues.

None yet

3 participants