Skip to content

Instantly share code, notes, and snippets.

View devlongs's full-sized avatar

devlongs devlongs

View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
contract SimpleStorage {
uint256 favoriteNumber;
mapping(string => uint256) public nameToFavoriteNumber;
struct People {
uint256 favoriteNumber;
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract Example3 {
uint256 count;
uint256 public time;
constructor(){
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.0;
contract Bank {
address public owner;
mapping(address => uint256) depositor;
address[] public depositors;
constructor() {
@devlongs
devlongs / Tuple.sol
Last active August 4, 2022 13:02
A snippet showing how tuple works in solidity.
// SPDX-License-Identifier:MIT
pragma solidity 0.8.0;
contract Tuple {
function getValues() public pure returns (int, bool) {
return (49, true);
}
function get() public pure returns (int) {
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract Vault {
// a contract where the owner create grant for a beneficiary;
//allows beneficiary to withdraw only when time elapse
//allows owner to withdraw before time elapse
//get information of a beneficiary
//amount of ethers in the smart contract
//SPDX-License-Identifier: GPL-3.0;
pragma solidity 0.8.7;
contract Energy {
//have total supply
//transferrable
//name
//symbol
//decimal
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.4;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";
contract Erc20Token is ERC20("fire on", "FIO") {
constructor() {
_mint(address(this), 10000e18);
}
@devlongs
devlongs / hashing.go
Created September 14, 2024 17:28
Hashing in Go using the crypto/sha256 library
package main
import (
"crypto/sha256"
"fmt"
)
func main() {
hash := sha256.New()
hash.Write([]byte("Hello, World!"))
@devlongs
devlongs / keccak256_hashing.go
Last active September 14, 2024 17:54
Keccahk256 hashing in Go using the golang.org/x/crypto/sha3 library
package main
import (
"fmt"
"golang.org/x/crypto/sha3"
)
func main() {
data := "Hello, Ethereum!"
package main
import (
"crypto/ecdsa"
"fmt"
"log"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
)