This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @notice The minimum payment required to use breedWithAuto(). This fee goes towards | |
/// the gas cost paid by whatever calls giveBirth(), and can be dynamically updated by | |
/// the COO role as the gas price changes. | |
uint256 public autoBirthFee = 2 finney; | |
/// @notice Have a pregnant Kitty give birth! | |
/// @param _matronId A Kitty ready to give birth. | |
/// @return The Kitty ID of the new kitten. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool ret; | |
address addr; | |
assembly { | |
let size := mload(0x40) | |
mstore(size, msgHash) | |
mstore(add(size, 32), v) | |
mstore(add(size, 64), r) | |
mstore(add(size, 96), s) | |
ret := call(3000, 1, 0, size, 128, size, 32) | |
addr := mload(size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int secp256k1_ecdsa_sig_recover(const secp256k1_ecmult_context *ctx, const secp256k1_scalar *sigr, const secp256k1_scalar* sigs, secp256k1_ge *pubkey, const secp256k1_scalar *message, int recid) { | |
unsigned char brx[32]; | |
secp256k1_fe fx; | |
secp256k1_ge x; | |
secp256k1_gej xj; | |
secp256k1_scalar rn, u1, u2; | |
secp256k1_gej qj; | |
int r; | |
if (secp256k1_scalar_is_zero(sigr) || secp256k1_scalar_is_zero(sigs)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ECRECOVER implemented as a native contract. | |
type ecrecover struct{} | |
func (c *ecrecover) RequiredGas(input []byte) uint64 { | |
return params.EcrecoverGas | |
} | |
func (c *ecrecover) Run(input []byte) ([]byte, error) { | |
const ecRecoverInputLength = 128 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EC.prototype.sign = function sign(msg, key, enc, options) { | |
if (typeof enc === 'object') { | |
options = enc; | |
enc = null; | |
} | |
if (!options) | |
options = {}; | |
key = this.keyFromPrivate(key, enc); | |
msg = this._truncateToN(new BN(msg, 16)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For eth_sign, we need to sign arbitrary data: | |
signMessage (withAccount, data) { | |
const wallet = this._getWalletForAccount(withAccount) | |
const message = ethUtil.stripHexPrefix(data) | |
var privKey = wallet.getPrivateKey() | |
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey) | |
var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s)) | |
return Promise.resolve(rawMsgSig) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getOriginAddress(bytes32 signedMessage, uint8 v, bytes32 r, bytes32 s) constant returns(address) { | |
bytes memory prefix = "\x19Ethereum Signed Message:\n32"; | |
bytes32 prefixedHash = keccak256(prefix, signedMessage); | |
return ecrecover(prefixedHash, v, r, s); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const message = web3.sha3('Hello World'); | |
const signature = await web3.eth.sign(account, message); | |
const { v, r, s } = ethUtil.fromRpcSig(signature); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.16; | |
contract Token { | |
bytes32 public standard; | |
bytes32 public name; | |
bytes32 public symbol; | |
uint256 public totalSupply; | |
uint8 public decimals; | |
bool public allowTransactions; | |
mapping (address => uint256) public balanceOf; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tradeBalances(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address user, uint amount) private { | |
uint feeMakeXfer = safeMul(amount, feeMake) / (1 ether); | |
uint feeTakeXfer = safeMul(amount, feeTake) / (1 ether); | |
uint feeRebateXfer = 0; | |
if (accountLevelsAddr != 0x0) { | |
uint accountLevel = AccountLevels(accountLevelsAddr).accountLevel(user); | |
if (accountLevel==1) feeRebateXfer = safeMul(amount, feeRebate) / (1 ether); | |
if (accountLevel==2) feeRebateXfer = feeTakeXfer; | |
} | |
tokens[tokenGet][msg.sender] = safeSub(tokens[tokenGet][msg.sender], safeAdd(amount, feeTakeXfer)); |
NewerOlder