I hereby claim:
- I am kswang on github.
- I am kswang (https://keybase.io/kswang) on keybase.
- I have a public key whose fingerprint is 0A38 0D6D 151F 9E78 1B6D 32D7 43A1 EE46 2170 6F31
To claim this, I am signing this object:
| event Log(string msg, uint value); | |
| function sendCoin(address receiver, uint amount) public returns(bool sufficient) { | |
| if (balances[msg.sender] < amount) return false; | |
| emit Log("step 1", amount); | |
| balances[msg.sender] -= amount; | |
| emit Log("step 2", amount); | |
| balances[receiver] += amount; | |
| emit Log("step 3", amount); | |
| emit Transfer(msg.sender, receiver, amount); | |
| return true; |
| pragma solidity ^1.4.18; | |
| import "./ConvertLib.sol"; | |
| // This is just a simple example of a coin-like contract. | |
| // It is not standards compatible and cannot be expected to talk to other | |
| // coin/token contracts. If you want to create a standards-compliant | |
| // token, see: https://github.com/ConsenSys/Tokens. Cheers! | |
| contract MetaCoin { |
| const MetaCoin = artifacts.require("MetaCoin"); | |
| contract('2nd MetaCoin test', async (accounts) => { | |
| it("should put 10000 MetaCoin in the first account", async () => { | |
| let instance = await MetaCoin.deployed(); | |
| let balance = await instance.getBalance.call(accounts[0]); | |
| assert.equal(balance.valueOf(), 10000); | |
| }) | |
| var MetaCoin = artifacts.require("./MetaCoin.sol"); | |
| contract('MetaCoin', function(accounts) { | |
| it("should put 10000 MetaCoin in the first account", function() { | |
| return MetaCoin.deployed().then(function(instance) { | |
| return instance.getBalance.call(accounts[0]); | |
| }).then(function(balance) { | |
| assert.equal(balance.valueOf(), 10000, "10000 wasn't in the first account"); | |
| }); | |
| }); |
| Observable<Transaction> myCatchUpToLatestAndSubscribeToNewTransactionsObservable( | |
| DefaultBlockParameter startBlock) { | |
| return web3j.catchUpToLatestAndSubscribeToNewBlocksObservable(startBlock, false) | |
| .flatMap(currentBlock -> { | |
| BigInteger confirmedBlock = currentBlock.getBlock().getNumber().subtract(confirmationBlock); | |
| return web3j.ethGetBlockByNumber(DefaultBlockParameter.valueOf(confirmedBlock), true).observable(); | |
| }).flatMapIterable(MyWeb3j::toTransactions); | |
| } |
| // Main.java | |
| public void subscribe() { | |
| Web3j web3j = Web3j.build(new HttpService("http://123.123.123:8545")); // your ethereum clinet | |
| List<Handler> handlers = Lists.newArrayList(new OwnershipTransferredEventHandler()); // init all the handler objects | |
| String[] topics = handlers.stream().map(Handler::getTopic).toArray(String[]::new); | |
| EthFilter filter = new EthFilter(startBlock, DefaultBlockParameterName.LATEST, contractAddress); | |
| filter.addOptionalTopics(topics); | |
| Subscription subscription = web3j.ethLogObservable(filter) |
| public class MyContract extends Contract { | |
| private static final String BINARY = ""; | |
| public static final Event OWNERSHIPTRANSFERRED_EVENT = new Event("OwnershipTransferred", | |
| Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {})); | |
| public Observable<OwnershipTransferredEventResponse> ownershipTransferredEventObservable(EthFilter filter) { | |
| return web3j.ethLogObservable(filter).map(new Func1<Log, OwnershipTransferredEventResponse>() { | |
| @Override | |
| public OwnershipTransferredEventResponse call(Log log) { |
| 042530a350d04e6bd37080fce4fd1a87ba70793f8ec6d29804fbcbea5a07a9480a9c14c52570055fb939aff09d7636424cbfca4bbe94742188fee832c167fc7e53 |
I hereby claim:
To claim this, I am signing this object: