Skip to content

Instantly share code, notes, and snippets.

@Husteem
Created May 23, 2024 20:17
Show Gist options
  • Select an option

  • Save Husteem/50a43c22e873cd13d040e5de4999369d to your computer and use it in GitHub Desktop.

Select an option

Save Husteem/50a43c22e873cd13d040e5de4999369d to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.0+commit.c7dfd78e.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
//fixed arrays
contract arrays {
uint[4] public id = [5, 10, 15, 20];
function size(uint no, uint new_id) public {
id[no] = new_id;
}
function len()public view returns(uint) {
return id.length;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract booll {
function apple(int figure) pure public returns (bool ) {
bool units = true;
if (figure > 1) {
return units;
}
units = false;
return units;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract constructorr {
uint public size;
constructor (uint newsize) {
size = newsize;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract dynamic_arrays {
uint[] public kano=[4];
function adder(uint king) public {
kano.push(king);
}
function remover() public {
kano.pop();
}
function lenth() public view returns (uint) {
return kano.length;
}
}
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract demo
{
int number;
constructor() {
number = 5;
}
function getter () public view returns (int)
{
return number;
}
function setter() public {
number=number+1;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract functionn
{
int public age = 10;
string public name = "husteemah";
function adder() public {
age = age+1;
}
function disrupt(int newage, string memory newname)public {
age = newage;
name = newname;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0 ;
contract demo
{
string public greetings = "Hello World";
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract statement {
function cheker(int num) public pure returns ( string memory ) {
string memory answer;
if (num > 0) {
answer = "the input is greater than zero and true";
}
else if (num ==0) {
answer = "the input is greater than - and les than +";
} else {
answer = "then input is lesser than zero";
}
return answer;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract local {
// declearing local variable
function gett () public pure returns (uint) {
uint age = 20;
return age;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract stringg {
string public gm = "hello wor;d";
function japaneese() public pure returns (string memory) {
string memory gm2= "ohayouuuuuuu";
return gm2;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
// states in solidity > stored on chain and exucutes with ether
contract state {
uint public age ;
string public name = "husteemah";
// constructor () {
// age = 20;
// }
function getter () public {
age= 30;
}
function adder () public {
age = age+2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment