Slide 7
Slide 7 text
import * as ethers from 'ethers';
export class EthersService {
private currentProvider: any;
// 初期化
constructor() {
const providers = ethers.providers;
const network = providers.networks[networkName];
const myProvider = new providers.JsonRpcProvider('http://');
const infuraProvider = new providers.InfuraProvider(network, '');
this.currentProvider = new providers.FallbackProvider([ myProvider, infuraProvider ]);
}
// コントラクト取得
getContract(abi: any, address: string): any {
return new ethers.Contract(address, abi, this.currentProvider);
}
// ウォレット作成
getNewWallet(): any {
return ethers.Wallet.createRandom();
}
}