Skip to content

matr1xc0in/qtum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Qtum

A place for hackathon projects on Qtum.

Contract deployed on Qtum Testnet (Contract Wallet is): https://testnet.qtum.org/address/qPjMYwN7QnjC1mdJYfSJKrZiqXfRC4Ne61

Setting up a Test Integration environment

  1. Generate a key pair, launch the qtum key generator and type in the numbers of address you want.
./qtum_key_generator/generate_keys.sh
  1. Kick off your qtumd test instance, can be regtest or testnet, etc. We use testnet here so it simulates a production-like integration.
./docker/run-testnet.sh
  1. Launch a qcli shell to access the testnet, convinient script run-shell.sh is provided. Copy/paste qtum addresses generated from previous step and import into your running qtumd instance via importprivkey option.
QTUM_NETWORK=testnet ./docker/run-shell.sh 

and import the private key. You can fund your wallet via testnet faucet. and the qtum address for this test private key is qVuqcjpBmRYGjjVZm1q1LFa28KJGQYPepC.

# importprivkey "qtumprivkey" ( "label" ) ( rescan )
qcli importprivkey cRgRqGfiP7wTdhUR4k9z9QBWsuBvSXmcVT4SeEoUSea7dKC3MLw7 "from-keygen" true

Now, you have a running qtumd with funded qtum to play with.

  1. Exposing qtumd instance via docker is possible. As you can see, they are exposed on all interfaces with the ports (e.g. 3889, etc.).
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                                                                                                        NAMES
94c56e8bc73a        qtum-dev            "/bin/sh -c 'mkdir -…"   About a minute ago   Up About a minute   0.0.0.0:3889->3889/tcp, 0.0.0.0:9888->9888/tcp, 0.0.0.0:9899->9899/tcp, 3888/tcp, 0.0.0.0:13888->13888/tcp   qtum_myapp
$ docker port 94c56e8bc73a
3889/tcp -> 0.0.0.0:3889
9888/tcp -> 0.0.0.0:9888
9899/tcp -> 0.0.0.0:9899
13888/tcp -> 0.0.0.0:13888

You can allow others to interact with this instance to perform some task by utilizing the same wallet (address) you generated from previous step. This means:

Pros:

  • your application does not need to run a local qtum wallet (SPV)
  • your application does not need to manage the wallet (unlocking with password, etc.)
  • you can take advantage of the RPC APIs to make remote calls via other libraries (e.g. qtumjs or qweb3.js, etc)

Cons:

  • If the qtumd instance is compromised by anyone else, you lose your qtum.
  • You copied/pasted your private key expose risk, never ship your private key :-)
  • Moving your wallet around is more complex and exposed to more risk.

Note: This is why this is only for testing Otz...... so please don't do this in production. At least lock down and whitelist the IP that is accessing the docker instance, etc.

  1. Deploy your smart contract. Copy the contract into the container shared volume from your host machine, e.g.
cp -rp sc/contracts docker/testnet/qtum_data/

and now, if you are already running the ./docker/run-shell.sh console, you can access and deploy your contracts from the wallet created above qVuqcjpBmRYGjjVZm1q1LFa28KJGQYPepC directly by running:

cd /dapp
solar --qtum_rpc=$QTUM_RPC --qtum_sender=qVuqcjpBmRYGjjVZm1q1LFa28KJGQYPepC --optimize deploy --force contracts/SimpleGetSet.sol

e.g.

exec: solc [contracts/SimpleGetSet.sol --combined-json bin,metadata --optimize --allow-paths /dapp]
🚀  All contracts confirmed
   deployed contracts/SimpleGetSet.sol => 43b39311a957ced773bd5373d9c58338c53c48f5
/dapp $ qcli fromhexaddress 43b39311a957ced773bd5373d9c58338c53c48f5
qPjMYwN7QnjC1mdJYfSJKrZiqXfRC4Ne61

and you can look them up on https://testnet.qtum.org e.g. contract address - https://testnet.qtum.org/address/qPjMYwN7QnjC1mdJYfSJKrZiqXfRC4Ne61 qtum address balance - https://testnet.qtum.org/address/qVuqcjpBmRYGjjVZm1q1LFa28KJGQYPepC

  1. Now, integrate your application with me (the docker container).

About

A place for hackathon projects on Qtum

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published