Skip to content

Instantly share code, notes, and snippets.

@code-brewer
Created September 28, 2018 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-brewer/257ac5ccc4160ca4029b2dc2cd2d813e to your computer and use it in GitHub Desktop.
Save code-brewer/257ac5ccc4160ca4029b2dc2cd2d813e 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.4.25+commit.59dbf8f1.js&optimize=false&gist=
pragma solidity 0.4.25;
/*数组类型Demo*/
contract DemoTypes303 {
/*String数组例子*/
string[] strArr;
function add(string str) public {
strArr.push(str);
}
function getStrAt(uint n) public constant returns (string s){
string storage tmp = strArr[n];
return tmp;
}
function updateStrAt(uint n, string str) public {
strArr[n] = str;
}
function deleteStrAt(uint index) public {
uint len = strArr.length;
if (index >= len) return;
for (uint i = index; i<len-1; i++) {
strArr[i] = strArr[i+1];
}
delete strArr[len-1];
strArr.length--;
}
}
pragma solidity ^0.4.25;
contract EventFilterTest {
constructor() public {
b = 0x12345678901234567890123456789012;
}
event Event(uint indexed a, bytes32 b) ;
event Event2(uint indexed a, bytes32 b) ;
function foo(uint a) public {
emit Event(a, b);
emit Event2(a, b);
}
bytes32 b;
}
pragma solidity ^0.4.25;
contract SimpleStorage {
uint public data;
// event SetX(address indexed _from, uint value);
event Set(string label, uint value);
function set(uint x) public {
data = x;
// emit SetX(msg.sender, x);
// emit Set("#####", x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment