Skip to content

Instantly share code, notes, and snippets.

@Zfinix
Created July 22, 2022 16:29
Show Gist options
  • Save Zfinix/d01384479f60cfed04bce5dc8a6f8ea4 to your computer and use it in GitHub Desktop.
Save Zfinix/d01384479f60cfed04bce5dc8a6f8ea4 to your computer and use it in GitHub Desktop.
import 'package:http/http.dart';
import 'package:lock/contracts/Lock.g.dart';
import 'package:web3dart/web3dart.dart';
void main(List<String> args) async {
const rpcUrl = 'http://127.0.0.1:8545';
final client = Web3Client(rpcUrl, Client());
final credentials = EthPrivateKey.fromHex(
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', /// This is generated by hardhat, not a real account
);
final lock = Lock(
address:
EthereumAddress.fromHex('0x5FbDB2315678afecb367f032d93F642f64180aa3'), /// This is generated by hardhat, not a real account
client: client,
);
lock.withdrawalEvents().listen(
(WithdrawalEvent event) {
print(event);
},
);
print(await lock.owner());
print(await lock.unlockTime());
print(await lock.withdraw(credentials: credentials));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment