Guide to work with the smart contract of the lottery EtherWinX25

Guide to work with the smart contract of the lottery EtherWinX25

EtherWin team

ATTENTION! The UI / UX of the lottery is in development currently. Soon you’ll be able to participate in our lottery at ewlottery.com, enjoying its convenient and user-friendly design. As for right now, you can already participate in the lottery by adding the smart contract to your wallet wallet.ethereum.org (see the manual).


To start working with the lottery smart contract:

1. Install MetaMask extension for Google Chrome, or the desktop version of your wallet.

2. Get ether via Rinkeby testnet.


Joining EtherWinX25 smart contract via wallet.ethereum.org

1.   Visit https://wallet.ethereum.org/.

(Important!) Ensure you have installed and logged into MetaMask and are connected to the Rinkeby test network.

If you’ve done everything correctly, you’ll see the wallet page with your account balance.

2. Click the “Contracts” tab, and then “Watch Contract

Enter the contract parameters:

Address - 0x13016f4c5354d5477abfc699b35cd3fab5fde84e .

Name – EtherWinX25 (you can choose any name).

JSON interface – copy the code from https://gist.github.com/KoltsovAnton/6eaa4881deeb6b94875135c17e4a2bb8 in its entirety (lines 1 to 749). Paste it into the interface field, then click “ОК”.

After that click the smart contract to access it.

Done!


Working with EtherWinX25 lottery’s smart contract in your wallet (wallet.ethereum.org)

Before participating in the lottery, please read the EtherWinX25 Lottery Rules.

1. Open the lottery smart contract by clicking on it. Now, first thing to do is to scroll down and mark the “Watch Events” checkbox.


2. Smart contract functions.

Click on the ”Select Function” menu on the right side of the smart contract page. You’ll see the drop-down list of functions.

To join in and participate in the lottery, you will only need the Play и Get Prize (the rest of the functions in the list are for developers only).

Use the Play function to buy lottery tickets and play. And you’ll need the Get Prize function to collect your winnings.


3. Buying lottery tickets.

Make sure you have installed and logged into MetaMask and are connected to the Rinkeby test network!

In the drop-down “Select Function” menu, select Play. In the appeared field, enter the ticket’s cost, from 0,005 to 0,05 ETH per address. After that, click EXECUTE.

In the MetaMask window, make sure Gas Limit is set to at least 147789 units, and Gas Price is in the range between 1 and 5 gwei. After the check, click the SUBMIT button.

After some time, the transaction will be added to the block (meaning that the ticket had participated in the lottery draw). The time for the transaction to get processed varies and depends on the network loadВремя включения транзакции в блок зависит от нагрузки сети and the chosen Gas Price value; usually taking under a minute. We recommend choosing Gas Price between 1 and 5 gwei.

To check whether your transaction has been included into the block, use MetaMask.

Or scroll down to check the smart contract events (look for New Ticket).

1 – this checkbox sould be marked
2 – ticket owner address
3 – the block Number
4 – cost of the ticket (in Wei)
5 – Block number with the lottery draw results

If you’ve done everything correctly, and the New Ticket event has been added to the smart contract, you can proceed to checking the results of the lottery draw.


4. Checkin the results.

The next consecutive block (after the one with the bought ticket transaction) includes results of the lottery draw. So, if N is the number of the block in which you bought you ticket, N+1 is the result block.

To get the exact block number with the results, check the result Block value in the New Ticket event.

Or click the ticket-buying transaction in MetaMask window.

Here you’ll get redirected to an etherscan page with your buying ticket transaction; the Block Height field value is the number of its block.

Since the results are in the next consecutive block, add 1 and get the results block number (In this particular case it’s 1994464 + 1 = 1994465).

Now take that result block number and run a search through Rinkeby testnet at https://rinkeby.etherscan.io/

You’ll get the full information regarding this block. To see whether your ticket is a winning one, check the very last symbol in the hash string.

Has it won? See in the table:

* multiply the ticket’s cost to the corresponding X number to determine your prize
** if the hash string ends with 99 you’ve just won jackpot!

In this particular draw our ticket is a lucky one (hash symbol “d”, meaning we get back the doubled cost of our ticket), now let’s proceed to collecting our X2 winnings!


5. Getting your winnings.

ATTENTION! It is possible to request a prize after 12 confirmations of the «Block Num (N)» block.

ATTENTION! Adding the winnings transaction block to the smart contract is possible no later than 1 hour after the lottery draw (256 blocks). This is dictated by the limited number of requests that Ethereum Smart Contracts can make to previously created blocks (platform limitations). This process will be automated once the site is launched. Running the Get Prize function adds the winning block to the smart contract. For each of the winning blocks, this function gets performed only once, with the first user request. In that case, the first user to request Get Prize for the particular block will get his/her payout transaction Gas Limit slightly increased. After that, all the other users that have won with that same block, will be able to collect their winning with marginally less Gas required to complete the transaction.

To collect your winnings, click “Select functions” >> “Get Prize” in the smart contract. In the appeared “Block num” field, enter the winning Result block number. Next, click EXECUTED

In the MetaMask window, make sure the Gas Price is in the range between 1 and 5 gwei. Gas Limit can reach 70 000 to 230 000 units (jackpot payout). After the check, click the SUBMIT button.

After the time nesessary for adding the winning payouts transactions to the block, your winnings will be added to your account balance. And the “Win Block Added” and “Send Prize” events will be added to the lottery’s smart contract.

ATTENTION! In case if you’ve done everything correctly, but still get the “transaction error” dialog popup, please reload the page with the lottery smart contract. Not forget, it is possible to request a prize after 12 confirmations of the «Block Num (N)» block.


6.   Current jackpot value

You can learn the current jackpot value by checking public variables of the lottery’s smart contract. To do this, use the result Block number of the last ticket purchaised (see smart contract events).

Scroll up to the Jackpot value field. Enter the number from result Block to Block num field. You will get the Wei value of the jackpot, for the minimal cost of the ticket.


Report Page