Skip to content

Instantly share code, notes, and snippets.

View MCarlomagno's full-sized avatar
🚀

Marcos Carlomagno MCarlomagno

🚀
  • OpenZeppelin
  • Rosario - Argentina
View GitHub Profile
pragma solidity >=0.7.0 <0.9.0;
contract Chat {
function sendMessage(string _text) public {
lastMessageId++;
// loads the message into the list.
messageList[messageIdCounter] = Message(
lastMessageId,
pragma solidity >=0.7.0 <0.9.0;
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/cryptography/ECDSA.sol";
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/utils/ReentrancyGuard.sol";
contract UniDirectionalPaymentChannel is ReentrancyGuard {
using ECDSA for bytes32;
address payable public sender;
address payable public receiver;
pragma solidity >=0.7.0 <0.9.0;
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/cryptography/ECDSA.sol";
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/utils/ReentrancyGuard.sol";
contract UniDirectionalPaymentChannel is ReentrancyGuard {
// ...
function _getHash(uint _amount) private view returns (bytes32) {
pragma solidity >=0.7.0 <0.9.0;
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/cryptography/ECDSA.sol";
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/utils/ReentrancyGuard.sol";
contract UniDirectionalPaymentChannel is ReentrancyGuard {
// ...
function _verify(uint _amount, bytes memory _sig) private view returns (bool) {
pragma solidity >=0.7.0 <0.9.0;
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/cryptography/ECDSA.sol";
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/utils/ReentrancyGuard.sol";
contract UniDirectionalPaymentChannel is ReentrancyGuard {
// ...
pragma solidity >=0.7.0 <0.9.0;
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/cryptography/ECDSA.sol";
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/utils/ReentrancyGuard.sol";
contract UniDirectionalPaymentChannel is ReentrancyGuard {
using ECDSA for bytes32;
address payable public sender;
address payable public receiver;
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
contract Persssist {
string public name = "Persssist";
uint256 public fileCount = 0;
// this mapping behaves as a "catalog"
// of files uploaded to the storage, we declare
// it as public in order to access it directly from the Frontend
it('deployed successfully', async () => {
const address = await this.contract.address
assert.notEqual(address, 0x0)
assert.notEqual(address, '')
assert.notEqual(address, null)
assert.notEqual(address, undefined)
})
it("uploads a valid file", async () => {
// checks filecount variable
// before uploading the file
const countBeforeUpload = await this.contract.fileCount();
await this.contract.uploadFile('path', 1, 'type', 'name');
// checks filecount increased
// by one after upload
const countAfterUpload = await this.contract.fileCount();
async fetchAccounts() {
if(typeof window === "undefined") return;
return window
.ethereum?.request({ method: "eth_accounts" })
.catch((err: any) => console.log(err));
}