Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blockchain/bitcoin/brainwallet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#coding:utf-8
#!/usr/bin/env python
import sys
from getpass import getpass
from bitcoin import *
Expand Down
6 changes: 6 additions & 0 deletions blockchain/crypto/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

## ecdsa

install
```
$ pip3 install ecdsa
```


## Steganography

install 7z on macosx.
Expand Down
12 changes: 12 additions & 0 deletions blockchain/ethereum/hardhat_sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules

#Hardhat files
cache
artifacts

#secret keys
.secrets.json

#temp files
.*~

54 changes: 54 additions & 0 deletions blockchain/ethereum/hardhat_sample/contracts/CryptoScientists.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract CryptoScientists is ERC721 {
uint256 public token_count = 0; // total count of token

address _minter;
mapping(uint256 => string) _token_hash; // ipfs hash for token[id]
mapping(string => bool) _hash_exists;

modifier onlyMinter {
require(_minter == msg.sender, "not minter");
_;
}

constructor() ERC721("Crypto Scientists NFT", "CSNFT") {
_minter = msg.sender;
}

function changeMinter(address m) public onlyMinter {
_minter = m;
}

function mint(string memory hash) public onlyMinter returns (uint256) {
require(_hash_exists[hash] == false, "already minted");
_hash_exists[hash] = true;

uint256 id = token_count;
token_count += 1;

_token_hash[id] = hash;
_safeMint(msg.sender, id);

return id;
}

function _baseURI() internal pure override returns (string memory) {
return "ipfs://ipfs/";
}

function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "nonexistent token");

string memory baseURI = _baseURI();
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, _token_hash[tokenId]))
: '';
}



}
48 changes: 48 additions & 0 deletions blockchain/ethereum/hardhat_sample/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-web3");
require("@nomiclabs/hardhat-etherscan");

//.secrets format: { "privkey":"....", "alchemyapikey":"...." }
const { privkey, alchemy_apikey, etherscan_apikey } = require("./.secrets.json");

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async () => {
const accounts = await ethers.getSigners();

for (const account of accounts) {
console.log(account.address);
}
});

// Added by Evan
task("balance", "Prints an account's balance [Evan's]")
.addParam("account", "The account's address")
.setAction(async taskArgs => {
const account = web3.utils.toChecksumAddress(taskArgs.account);
const balance = await web3.eth.getBalance(account);

console.log(web3.utils.fromWei(balance, "ether"), "ETH");
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
//solidity: "0.7.3",
solidity: "0.8.0",
networks: {
rinkeby: {
url: `https://eth-rinkeby.alchemyapi.io/v2/${alchemy_apikey}`,
accounts: [`0x${privkey}`]
}
},
etherscan: {
apiKey: etherscan_apikey
}

};

Loading