owned this note
owned this note
Published
Linked with GitHub
# Numerai Tournament Custom Staking
The process for custom staking has changed following the recent upgrade of the NMR token.
Custom staking now requires a two step process.
1. Approve tournament to perform token transfer.
2. Stake on the tournament.
## Approving Token Transfer
We recommend approving the tournament to transfer the maximum amount of tokens in order to avoid repeating this approval step every week. The easiest way to do this is to go to [myetherwallet](https://www.myetherwallet.com/interface/send-transaction) under send transaction. Note this method requires no approval has been previously given.
```
from: (wallet used for staking)
to: 0x1776e1F26f98b1A5dF9cD347953a26dd3Cb46671 (NMR token contract)
value: 0
data: 0x095ea7b30000000000000000000000009dce896ddc20ba883600176678cbee2b8ba188a9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff (approve max value)
gasLimit: 50000
```
![](https://i.imgur.com/yUaAnta.png)
An alternative is to send directly using web3 with an unlocked wallet:
```
web3.eth.sendTransaction({
from: (wallet used for staking),
to: '0x1776e1F26f98b1A5dF9cD347953a26dd3Cb46671',
data: '0x095ea7b30000000000000000000000009dce896ddc20ba883600176678cbee2b8ba188a9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
gas: 50000
})
/* Note: the data in the previous example was generated as follows */
calldata = web3.eth.abi.encodeFunctionCall(
{
"inputs": [
{
"name": "spender",
"type": "address"
},
{
"name": "value",
"type": "uint256"
}
],
"name": "approve",
"type": "function"
},[
'0x9DCe896DdC20BA883600176678cbEe2B8BA188A9',
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
]
)
```
## Staking
Staking requires interacting with the tournament contract directly. On [myetherwallet](https://www.myetherwallet.com/interface/interact-with-contract) go to interact with contract and input the required information.
**Contract Address:** `0x9DCe896DdC20BA883600176678cbEe2B8BA188A9`
**ABI/JSON Interface:** `[{"constant":false,"inputs":[{"name":"tournamentID","type":"uint256"},{"name":"roundID","type":"uint256"},{"name":"tag","type":"bytes32"},{"name":"stakeAmount","type":"uint256"},{"name":"confidence","type":"uint256"}],"name":"stake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]`
**Select an item:** `stake`
**TournamentID (uint256):** `7` (Kazutsugi)
**RoundID (uint256):** `roundId` (increments every week)
**Tag (bytes32):** `hex encoded username`
**StakeAmount (uint256):** `amount of nmr in wei` (multiply by 10^18)
**Confidence (uint256):** `3 decimals of confidence` (ex: .503 -> 503)
![](https://i.imgur.com/ksLdLVA.png)
The equivalent web3 version:
```
calldata = web3.eth.abi.encodeFunctionCall(
{
"inputs": [
{
"name": "tournamentID",
"type": "uint256"
},
{
"name": "roundID",
"type": "uint256"
},
{
"name": "tag",
"type": "bytes32"
},
{
"name": "stakeAmount",
"type": "uint256"
},
{
"name": "confidence",
"type": "uint256"
}
],
"name": "stake",
"type": "function"
},[
1,
166,
web3.utils.padLeft(web3.utils.utf8ToHex('quantverse'), 64),
web3.utils.toWei('1'),
503
]
)
web3.eth.sendTransaction({
from: (wallet used for staking),
to: '0x9DCe896DdC20BA883600176678cbEe2B8BA188A9',
data: calldata,
gas: 70000
})
```