Skip to content

Instantly share code, notes, and snippets.

View jamesmorgan's full-sized avatar

James Morgan jamesmorgan

View GitHub Profile
contract Structs {
struct Shipment {
// Slot 1: 20 bytes packed with bool (1 byte)
address receiver;
bool delivered;
// Slot 2: uint 8 + uint128 = 1 slot
uint8 typeCode;
uint128 price; (Max size: 170141183460469231731687303715884105727)
contract Sample {
uint256 a; // storage position 0
uint256[2] b; // storage position 1 & 2
// This is just declaration
struct TestStruct {
uint256 id;
uint256 value;
}
contract Structs {
struct Shipment {
address receiver;
uint price;
bool delivered;
string package;
uint8 typeCode;
}
pragma solidity ^0.6.0;
interface IERC2981 {
/// @notice Called with the sale price to determine how much royalty
// is owed and to whom.
/// @param _tokenId - the NFT asset queried for royalty information
/// @param _salePrice - the sale price of the NFT asset specified by _tokenId
/// @return receiver - address of who should be sent the royalty payment
/// @return royaltyAmount - the royalty payment amount for _salePrice

Keybase proof

I hereby claim:

  • I am jamesmorgan on github.
  • I am jimbobbins (https://keybase.io/jimbobbins) on keybase.
  • I have a public key ASDJX-FTTS6FHG0_HJcGRAdgzch4rm2N1q_boL8en4HdGQo

To claim this, I am signing this object:

did:muport:QmYNX951337ofvFM8k5HSF9vg51H363bRpDtXvqJPSfRU5
@jamesmorgan
jamesmorgan / revert-reasons.js
Last active January 2, 2019 10:17
revert-reasons.js
try {
await contract.methodCall();
} catch (error) {
// error.reason now populated with an REVERT reason
console.log("Failure reason", error.reason);
}
@jamesmorgan
jamesmorgan / truffle.js
Last active January 2, 2019 10:02
truffle.js
{
live: {
network_id: 1,
gas: 6075039,
gasPrice: 5000000000,
timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
}
}
@jamesmorgan
jamesmorgan / transaction-handling.js
Last active September 29, 2019 11:02
transaction-handling.js
contract
.purchase(edition.edition, {
from: account,
value: priceInWei
})
.on('transactionHash', hash => {
console.log('Purchase transaction submitted', hash);
})
.on('receipt', receipt => {
console.log('Purchase successful - Ive been mined', receipt);
@jamesmorgan
jamesmorgan / erc-721-enhanced-metadata.json
Last active March 12, 2024 09:14
erc-721-enhanced-metadata.json
{
"title": "Asset Metadata",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Identifies the asset to which this NFT represents",
},
"description": {
"type": "string",