This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2024-08-28", | |
"Statement": [ | |
{ | |
"Sid": "VisualEditor0", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:GetRole", | |
"logs:DeleteLogGroup", | |
"apigateway:PUT", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buy(uint256 tokenId) payable { | |
require(msg.value >= price, "Payment not enough"); | |
address _currentOwner = ownerOf(tokenId); | |
_transfer(_currentOwner, msg.sender, tokenId); | |
bool sent = _currentOwner.send(msg.value); | |
require(sent, "Failed to send Ether"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// contracts/Version1-Safe.sol | |
pragma solidity ^0.8.0; | |
interface IERC20 { | |
function transferFrom(address from, address to, uint256 value) external returns(bool); | |
function transfer(address to, uint256 value) external returns(bool); | |
} | |
contract Bank2 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// contracts/Version1-Safe.sol | |
pragma solidity ^0.8.0; | |
interface IERC20 { | |
function transferFrom(address from, address to, uint256 value) external returns(bool); | |
function transfer(address to, uint256 value) external returns(bool); | |
} | |
contract Bank { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
** pipex.c - multipipes support | |
*/ | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
/* | |
* loop over commands by sharing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
/** | |
A simple Solidity smart contract which generates a random number between 0 and the desired max number. | |
Uses two functions to generate the random number: | |
- First "prepareRandom" should be called. The function will set the "preparationBlockNumber" to the current block number. | |
- Second "roll" should be called to generate the number. The function generates a random number using the blockhash of the block when "prepareRandom" has been called. This way, as the blockhash of the block can't be know before the "prepareRandom" transaction goes thorugh, | |
the result of the roll can't be predicted and thus manipulated. | |
How many times the roll has been called and all the previous results are recorded in the blockchain. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.0; | |
contract RandomNumbers{ | |
// Result varibles | |
uint256[] public winnerNumbers; | |
uint256 public rollCount; | |
function random(uint256 maxNumber) public view returns (uint256) { | |
/** | |
Generates a random number between 0 and maxNumber. Uses current block difficulty, timestamp, caller address, and the blockhash of the block when prepareRandom has been called. | |
Although the output of this function can be precalculated, the manager not knowing the blockhash of the block they called "prepareRandom" makes the system fair. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.0; | |
contract RandomNumbers{ | |
uint256 public preparationBlockNumber; | |
bool public canCallRandom; | |
function prepareRandom() public { | |
/** | |
When called sets the preparation block number to the current block number. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://blog.finxter.com/how-to-generate-random-numbers-in-solidity/ | |
pragma solidity ^0.8.0; | |
contract RandomNumbers{ | |
function createRandom(uint number) public view returns(uint){ | |
return uint(blockhash(block.number-1)) % number; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://blog.finxter.com/how-to-generate-random-numbers-in-solidity/ | |
pragma solidity ^0.8.0; | |
contract RandomNumbers{ | |
function random(uint number) public view returns(uint){ | |
return uint(keccak256(abi.encodePacked(block.timestamp,block.difficulty, | |
msg.sender))) % number; | |
} | |
} |
NewerOlder