Skip to content

Instantly share code, notes, and snippets.

@BellaBe
BellaBe / smart-contract-interaction.js
Last active July 31, 2023 18:31
How to interact with Pancakeswap Prediction Smart Contract
const { default: axios } = require("axios");
const Web3 = require("web3");
const provider = "https://bsc-dataseed1.binance.org:443";
const web3 = new Web3(provider);
const contractAddress = "0x18B2A687610328590Bc8F2e5fEdDe3b582A49cdA";
const execute = async() => {
@BellaBe
BellaBe / DemoSingleInheritance.sol
Created December 29, 2022 15:16
Parent child single inheritance Smart contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract ParentContract{
uint internal simpleInteger;
function setInteger(uint _value) external{
simpleInteger = _value;
}
}
@BellaBe
BellaBe / DemoWithConstructor.sol
Created December 29, 2022 15:10
Create Smart contract with constructor
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract Demo {
uint private simpleUint;
constructor() {
simpleUint = 5;
}
function getValue() public view returns(uint){
return simpleUint;
@BellaBe
BellaBe / DemoDeployedContract.sol
Last active December 29, 2022 15:07
Create Smart contract with already deployed contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
// usage: contract is already deployed and instantiated, a reference to it is made by using its address
contract DeployedDemo{
uint private simpleUint;
constructor() payable{}
function getValue() public view returns(uint){
return simpleUint;
}
@BellaBe
BellaBe / DemoNewWithSaltAndValue.sol
Last active December 29, 2022 14:59
Create Smart contract with new keyword, salt and initial value
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
// usage: one contract(client) deploys and creates a new insatnce of another contract(Demo) by using new keyword, salt and initial value
contract Demo{
uint private simpleUint;
constructor() payable{}
function getValue() public view returns(uint){
return simpleUint;
}
@BellaBe
BellaBe / DemoNewWithSalt.sol
Last active December 29, 2022 14:59
Create Smart contract with new and salt
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
// usage: one contract(client) deploys and creates a new insatnce of another contract(Demo) by using new keyword and salt
contract Demo{
uint private simpleUint;
constructor() payable{}
function getValue() public view returns(uint){
return simpleUint;
}
@BellaBe
BellaBe / Demo.sol
Last active December 29, 2022 14:54
Create Smart contract with new keyword
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
// usage: one contract(client) deploys and creates a new insatnce of another contract(Demo) by using new keyword
contract Demo {
uint private simpleUint;
constructor() payable{}
function getValue() public view returns(uint){
return simpleUint;
@BellaBe
BellaBe / GeneralStructure.sol
Created December 29, 2022 12:57
Smart contract general structure
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract GeneralStructure{
// state variables
uint public stateUintVariable;
string stateStringVariable;
address owner;
Person person;