Skip to content

Instantly share code, notes, and snippets.

View sampathkumarspace's full-sized avatar

sampathkumarspace

View GitHub Profile
@sampathkumarspace
sampathkumarspace / contracts...artifacts...mapping.sol
Created August 29, 2022 18:28
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.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier:MIT
pragma solidity ^0.8.7;
contract Smapping{
//mapping
//mapping(keytype => vauletype)visibility identifier; // similar to array , can get value with index number here you can get value with key which you assign for value
// you can add more values
mapping(uint => mapping (uint => string)) person;
@sampathkumarspace
sampathkumarspace / contracts...artifacts...Array.sol
Created August 29, 2022 18:28
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.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier:MIT
pragma solidity ^0.8.7;
contract arrays{
uint[] public numbers = [1, 2, 3]; //dynamic array size not fixed
int [3] public intnum = [-2, 3, 4]; // integers must be with -ve value in arrays
// fixed Size array and dynamic
// push (add value in array)
@sampathkumarspace
sampathkumarspace / contracts...artifacts...Function.sol
Last active August 29, 2022 18:28
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.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier:MIT
pragma solidity ^0.8.7;
contract simfun{
string public constant name = "Sam"; // used constant to use pure in funtion if it is public then we can remove constant
//function identifier() public view /pure returns(){ return name;}
function fun()public pure returns(string memory) {
@sampathkumarspace
sampathkumarspace / contracts...artifacts...Simple.sol
Created August 29, 2022 18:27
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.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier:MIT
//This Program is about to understand datatypes in solidity
pragma solidity ^0.8.7;
contract Simple{
//int, uint, string, address, bool
int public num = 369;
uint private unum = 7; //no -ve value or 0 allowed
string public nam = "sam";