Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

update Migrations.sol template code #1296

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/docs/truffle/getting-started/running-migrations.md
Original file line number Diff line number Diff line change
@@ -78,7 +78,8 @@ Truffle requires you to have a Migrations contract in order to use the Migration
Filename: `contracts/Migrations.sol`

```solidity
pragma solidity ^0.4.8;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Migrations {
address public owner;
@@ -87,19 +88,20 @@ contract Migrations {
uint public last_completed_migration;

modifier restricted() {
if (msg.sender == owner) _;
require(msg.sender == owner);
_;
}

function Migrations() {
constructor() {
owner = msg.sender;
}

// A function with the signature `setCompleted(uint)` is required.
function setCompleted(uint completed) restricted {
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}

function upgrade(address new_address) restricted {
function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}