Skip to content

Instantly share code, notes, and snippets.

View qiwihui's full-sized avatar
🦉
Focusing

qiwihui qiwihui

🦉
Focusing
View GitHub Profile

Sending Ether Cheat Sheet

TLDR

🥇 Instead of sending Ether, use the withdrawal pattern

🥈 If you really need to send Ether, use a safe wrapper like OpenZeppelin's Address.sendValue(addr, amount)

🥉 If you really need to send Ether without dependencies, use (bool success, ) = addr.call{value: amount}("")

@qiwihui
qiwihui / gist:86e7385c635f88b539ed2f032018ca28
Created January 27, 2023 15:26
sui client object 0x84fe8e597bcb9387b2911b5ef39b90bb111e71a2
$ sui client object 0x84fe8e597bcb9387b2911b5ef39b90bb111e71a2
----- Move Object (0x84fe8e597bcb9387b2911b5ef39b90bb111e71a2[539]) -----
Owner: Account Address ( 0x659f89084673bf4a993cdea89a94dabf93a2ddb4 )
Version: 539
Storage Rebate: 289
Previous Transaction: 7p1nmTPYE9884gBCJL6sah2t6Vzh9P59MUeFVURXaEFx
----- Data -----
type: 0x59a85fbef4bc17cd73f8ff89d227fdcd6226c885::token_helper::FoxOrChicken
alpha: 5
@qiwihui
qiwihui / a
Created November 20, 2022 13:39
data:application/json;base64,eyJuYW1lIjogIlNoZWVwICMxIiwgImRlc2NyaXB0aW9uIjogIlRob3VzYW5kcyBvZiBTaGVlcCBhbmQgV29sdmVzIGNvbXBldGUgb24gYSBmYXJtIGluIHRoZSBtZXRhdmVyc2UuIEEgdGVtcHRpbmcgcHJpemUgb2YgJFdPT0wgYXdhaXRzLCB3aXRoIGRlYWRseSBoaWdoIHN0YWtlcy4gQWxsIHRoZSBtZXRhZGF0YSBhbmQgaW1hZ2VzIGFyZSBnZW5lcmF0ZWQgYW5kIHN0b3JlZCAxMDAlIG9uLWNoYWluLiBObyBJUEZTLiBOTyBBUEkuIEp1c3QgdGhlIEV0aGVyZXVtIGJsb2NrY2hhaW4uIiwgImltYWdlIjogImRhdGE6aW1hZ2Uvc3ZnK3htbDtiYXNlNjQsUEhOMlp5QnBaRDBpZDI5dmJHWWlJSGRwWkhSb1BTSXhNREFsSWlCb1pXbG5hSFE5SWpFd01DVWlJSFpsY25OcGIyNDlJakV1TVNJZ2RtbGxkMEp2ZUQwaU1DQXdJRFF3SURRd0lpQjRiV3h1Y3owaWFIUjBjRG92TDNkM2R5NTNNeTV2Y21jdk1qQXdNQzl6ZG1jaUlIaHRiRzV6T25oc2FXNXJQU0pvZEhSd09pOHZkM2QzTG5jekxtOXlaeTh4T1RrNUwzaHNhVzVySWo0OGFXMWhaMlVnZUQwaU5DSWdlVDBpTkNJZ2QybGtkR2c5SWpNeUlpQm9aV2xuYUhROUlqTXlJaUJwYldGblpTMXlaVzVrWlhKcGJtYzlJbkJwZUdWc1lYUmxaQ0lnY0hKbGMyVnlkbVZCYzNCbFkzUlNZWFJwYnowaWVFMXBaRmxOYVdRaUlIaHNhVzVyT21oeVpXWTlJbVJoZEdFNmFXMWhaMlV2Y0c1bk8ySmhjMlUyTkN4cFZrSlBVbmN3UzBkbmIwRkJRVUZPVTFWb1JWVm5RVUZCUTBGQlFVRkJaME
@qiwihui
qiwihui / escrow.move
Created August 3, 2022 03:46
Escrow.move
/// @title Escrow
/// @dev Basic escrow module: holds an object designated for a recipient until the sender approves withdrawal.
module SFC::Escrow {
use StarcoinFramework::Signer;
use StarcoinFramework::Option::{Self, Option};
struct Escrow<T: key + store> has key {
recipient: address,
obj: Option<T>
}
@qiwihui
qiwihui / HelloWorld.sol
Created April 25, 2022 02:40
HelloWorld.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract HellowWorld {
uint256 number;
function storeNumber(uint256 num) public {
number = num;
@qiwihui
qiwihui / Ballot.sol
Last active April 24, 2022 07:44
Ballot with 5 minutes limited.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/// @title Voting with delegation.
contract Ballot {
// This declares a new complex type which will
// be used for variables later.
// It will represent a single voter.
struct Voter {
uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted
'''Train a simple deep NN on the MNIST dataset.
Get to 98.40% test accuracy after 20 epochs
(there is *a lot* of margin for parameter tuning).
2 seconds per epoch on a K520 GPU.
'''
import numpy as np
np.random.seed(1337) # for reproducibility
from functools import partial
from keras.datasets import mnist
@qiwihui
qiwihui / hwtemp.md
Created June 21, 2019 02:12
monitoring cpu temperature
$ sudo apt-get install lm-sensors
$ sudo sensors-detect
$ sensors

iwlwifi-virtual-0
Adapter: Virtual device
temp1:        +57.0°C

acpitz-virtual-0
@qiwihui
qiwihui / pandoc.md
Created February 26, 2019 05:29
pandoc cheat sheet

Convert makrdown to reStructuredText

pandoc --from=markdown --to=rst --output=README.rst README.md
@qiwihui
qiwihui / .travis.yml
Created October 31, 2018 07:57 — forked from willprice/.travis.yml
How to set up TravisCI for projects that push back to github
# Ruby is our language as asciidoctor is a ruby gem.
lang: ruby
before_install:
- sudo apt-get install pandoc
- gem install asciidoctor
script:
- make
after_success:
- .travis/push.sh
env: