This file contains hidden or 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
| import { Injectable } from '@angular/core'; | |
| import { EthService } from './service'; | |
| // NGRX | |
| import { Action } from '@ngrx/store'; | |
| import { Effect, Actions } from '@ngrx/effects'; | |
| import { EthError } from './../eth/actions'; | |
| import { GET_ACCOUNTS, GetAccountsSuccess } from './actions'; |
This file contains hidden or 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
| import { EthState } from './eth.reducers'; | |
| export const getAccounts = (state: EthState) => state.eth.accounts; | |
| export const getDefaultAccount = (state: EthState) => state.eth.selected; |
This file contains hidden or 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
| import { NgModule, ModuleWithProviders, Type } from '@angular/core'; | |
| import { CommonModule } from '@angular/common'; | |
| // Web3 | |
| import { WEB3 } from './tokens'; | |
| const Web3 = require('web3'); | |
| // SERVICES | |
| import { AccountsService } from './eth.services'; | |
| // NGRX | |
| import { StoreModule } from '@ngrx/store'; |
This file contains hidden or 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
| import { Component, OnInit } from '@angular/core'; | |
| // NGRX | |
| import { Store, select } from '@ngrx/store'; | |
| import { EthState, GetAccounts, getAccounts } from './ethereum'; | |
| // RXJS | |
| import { Observable } from 'rxjs/Observable'; | |
| @Component({ |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <title>DAPP</title> | |
| </head> | |
| <body> | |
| <script src="web3.min.js"></script> | |
| <script src="main.js"></script> |
This file contains hidden or 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 web3 = new Web3('https://ropsten.infura.io/your-id'); | |
| // Create a account and store it encrypted in the localStorage | |
| function createAndSaveAccount() { | |
| const password = prompt('Mot de passe encrypter le compte'); | |
| const account = web3.eth.accounts.create(); | |
| const keystore = account.encrypt(password); | |
| localStorage.setItem('keystore', JSON.stringify(keystore)); | |
| } |
This file contains hidden or 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 bip39 = require('bip39'); | |
| const HDKey = require('hdkey'); | |
| const Web3 = require('web3'); | |
| const web3 = new Web3('https://ropsten.infura.io/your-id'); | |
| const mnemonic = bip39.generateMnemonic(); | |
| confirm(mnemonic); | |
| const seed = bip39.mnemonicToSeed(mnemonic); | |
| const masterNode = HDKey.fromMasterSeed(seed); | |
| const derivationKey = "m/44'/60'/0'/0'/0"; |
This file contains hidden or 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.23; | |
| contract MessageSender { | |
| mapping(address => string) public messages; | |
| function sendMessage(address to, string content) public { | |
| messages[to] = content; | |
| } | |
| } |
This file contains hidden or 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.23; | |
| contract MessageSender { | |
| struct Message { | |
| address from; | |
| string content; | |
| } | |
| mapping(address => Message) public messages; |
This file contains hidden or 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
| import { environment } from '../environments/environment'; | |
| import { bindNodeCallback, Observable } from 'rxjs'; | |
| @Injectable({ providedIn: 'root' }) | |
| export class Web3Service { | |
| public web3: Web3; | |
| constructor() { | |
| this.web3 = new Web3(environment.web3Provider); |